first working version of chat functionality

This commit is contained in:
Volker Fischer 2008-07-24 16:20:25 +00:00
parent 24d57c412f
commit 70d368c9b7
16 changed files with 182 additions and 88 deletions

View file

@ -71,12 +71,12 @@ CChannelSet::CChannelSet()
QObject::connect(&vecChannels[5],SIGNAL(NameHasChanged()),this,SLOT(OnNameHasChangedCh5()));
// chate text received
QObject::connect(&vecChannels[0],SIGNAL(ChatTextReceived()),this,SLOT(OnChatTextReceivedCh0()));
QObject::connect(&vecChannels[1],SIGNAL(ChatTextReceived()),this,SLOT(OnChatTextReceivedCh1()));
QObject::connect(&vecChannels[2],SIGNAL(ChatTextReceived()),this,SLOT(OnChatTextReceivedCh2()));
QObject::connect(&vecChannels[3],SIGNAL(ChatTextReceived()),this,SLOT(OnChatTextReceivedCh3()));
QObject::connect(&vecChannels[4],SIGNAL(ChatTextReceived()),this,SLOT(OnChatTextReceivedCh4()));
QObject::connect(&vecChannels[5],SIGNAL(ChatTextReceived()),this,SLOT(OnChatTextReceivedCh5()));
QObject::connect(&vecChannels[0],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh0(QString)));
QObject::connect(&vecChannels[1],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh1(QString)));
QObject::connect(&vecChannels[2],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh2(QString)));
QObject::connect(&vecChannels[3],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh3(QString)));
QObject::connect(&vecChannels[4],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh4(QString)));
QObject::connect(&vecChannels[5],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh5(QString)));
}
CVector<CChannelShortInfo> CChannelSet::CreateChannelList()
@ -115,7 +115,7 @@ void CChannelSet::CreateAndSendChanListForAllConChannels()
}
}
void CChannelSet::CreateAndSendChatTextForAllConChannels ( const QString& strName )
void CChannelSet::CreateAndSendChatTextForAllConChannels ( const QString& strChatText )
{
// send chat text to all connected clients
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
@ -123,7 +123,7 @@ void CChannelSet::CreateAndSendChatTextForAllConChannels ( const QString& strNam
if ( vecChannels[i].IsConnected() )
{
// send message
vecChannels[i].CreateChatTextMes ( strName );
vecChannels[i].CreateChatTextMes ( strChatText );
}
}
}

View file

@ -115,9 +115,9 @@ public:
Protocol.CreateJitBufMes ( iJitBufSize );
}
}
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); }
void CreateChatTextMes ( const QString& strName ) { Protocol.CreateChatTextMes ( strName ); }
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); }
void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); }
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
{
@ -193,7 +193,7 @@ signals:
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ProtocolStatus ( bool bOk );
void NameHasChanged();
void ChatTextReceived ( QString strName );
void ChatTextReceived ( QString strChatText );
};
@ -238,8 +238,8 @@ protected:
CVector<CChannelShortInfo> CreateChannelList();
void CreateAndSendChanListForAllConChannels();
void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID );
void CreateAndSendChanListForThisChan ( const int iCurChanID );
void CreateAndSendChatTextForAllConChannels ( const QString& strName );
void CreateAndSendChanListForThisChan ( const int iCurChanID );
void CreateAndSendChatTextForAllConChannels ( const QString& strChatText );
/* do not use the vector class since CChannel does not have appropriate
copy constructor/operator */
@ -278,12 +278,12 @@ public slots:
void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); }
void OnChatTextReceivedCh0(QString strName) { CreateAndSendChatTextForAllConChannels(strName); }
void OnChatTextReceivedCh1(QString strName) { CreateAndSendChatTextForAllConChannels(strName); }
void OnChatTextReceivedCh2(QString strName) { CreateAndSendChatTextForAllConChannels(strName); }
void OnChatTextReceivedCh3(QString strName) { CreateAndSendChatTextForAllConChannels(strName); }
void OnChatTextReceivedCh4(QString strName) { CreateAndSendChatTextForAllConChannels(strName); }
void OnChatTextReceivedCh5(QString strName) { CreateAndSendChatTextForAllConChannels(strName); }
void OnChatTextReceivedCh0(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
void OnChatTextReceivedCh1(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
void OnChatTextReceivedCh2(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
void OnChatTextReceivedCh3(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
void OnChatTextReceivedCh4(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
void OnChatTextReceivedCh5(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
signals:
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );

View file

@ -30,7 +30,25 @@ CChatDlg::CChatDlg ( QWidget* parent, Qt::WindowFlags f )
{
setupUi ( this );
// clear chat window and edit line
TextViewChatWindow->clear();
lineEditLocalInputText->clear();
// Connections -------------------------------------------------------------
QObject::connect ( lineEditLocalInputText, SIGNAL ( returnPressed() ),
this, SLOT ( OnNewLocalInputText() ) );
}
void CChatDlg::OnNewLocalInputText()
{
// send new text and clear line afterwards
emit NewLocalInputText ( lineEditLocalInputText->text() );
lineEditLocalInputText->clear();
}
void CChatDlg::AddChatText ( QString strChatText )
{
// add new text in chat window
TextViewChatWindow->append ( strChatText );
}

View file

@ -43,4 +43,12 @@ class CChatDlg : public QDialog, private Ui_CChatDlgBase
public:
CChatDlg ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void AddChatText ( QString strChatText );
public slots:
void OnNewLocalInputText();
signals:
void NewLocalInputText ( QString strNewText );
};

View file

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>535</width>
<height>397</height>
<width>360</width>
<height>405</height>
</rect>
</property>
<property name="sizePolicy" >
@ -82,9 +82,9 @@
</layout>
</widget>
<tabstops>
<tabstop>TextViewChatWindow</tabstop>
<tabstop>lineEditLocalInputText</tabstop>
<tabstop>buttonClose</tabstop>
<tabstop>TextViewChatWindow</tabstop>
</tabstops>
<resources>
<include location="resources.qrc" />

View file

@ -31,7 +31,8 @@ CClient::CClient() : bRun ( false ), Socket ( &Channel ),
iReverbLevel ( AUD_REVERB_MAX / 6 ),
bReverbOnLeftChan ( false ),
iNetwBufSizeFactIn ( DEF_NET_BLOCK_SIZE_FACTOR ),
strIPAddress ( "" ), strName ( "" )
strIPAddress ( "" ), strName ( "" ),
bOpenChatOnNewMessage ( true )
{
// connection for protocol
QObject::connect ( &Channel,
@ -50,6 +51,9 @@ CClient::CClient() : bRun ( false ), Socket ( &Channel ),
QObject::connect ( &Channel, SIGNAL ( NewConnection() ),
this, SLOT ( OnNewConnection() ) );
QObject::connect ( &Channel, SIGNAL ( ChatTextReceived ( QString ) ),
this, SIGNAL ( ChatTextReceived ( QString ) ) );
}
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )

View file

@ -1,5 +1,5 @@
/******************************************************************************\
* Copyright (c) 2004-2006
* Copyright (c) 2004-2008
*
* Author(s):
* Volker Fischer
@ -75,6 +75,9 @@ public:
the sqaure root. */
double GetTimingStdDev() { return sqrt ( RespTimeMoAvBuf.GetAverage() ); }
bool GetOpenChatOnNewMessage() { return bOpenChatOnNewMessage; }
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
int GetAudioInFader() { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
@ -98,7 +101,6 @@ public:
}
int GetSockBufSize() { return Channel.GetSockBufSize(); }
void SetNetwBufSizeFactIn ( const int iNewNetNetwBlSiFactIn )
{
// store value and tell the server about new value
@ -119,6 +121,9 @@ public:
void SetRemoteName() { Channel.SetRemoteName ( strName ); }
void SendTextMess ( const QString& strChatText )
{ Channel.CreateChatTextMes ( strChatText ); }
CSound* GetSndInterface() { return &Sound; }
CChannel* GetChannel() { return &Channel; }
@ -151,6 +156,8 @@ protected:
int iNetwBufSizeFactIn;
bool bOpenChatOnNewMessage;
CVector<short> vecsAudioSndCrd;
CVector<double> vecdAudioSndCrdL;
CVector<double> vecdAudioSndCrdR;
@ -178,6 +185,7 @@ public slots:
signals:
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ChatTextReceived ( QString strChatText );
};

View file

@ -77,6 +77,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
double ( iCurNetBufSiFactOut * MIN_BLOCK_DURATION_MS), 'f', 2 ) +
" ms" );
// "OpenChatOnNewMessage" check box
if ( pClient->GetOpenChatOnNewMessage() )
{
cbOpenChatOnNewMessage->setCheckState ( Qt::Checked );
}
else
{
cbOpenChatOnNewMessage->setCheckState ( Qt::Unchecked );
}
// Connections -------------------------------------------------------------
// timers
@ -97,6 +107,10 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( SliderNetBufSiFactOut, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderNetBufSiFactOut ( int ) ) );
// check boxes
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) );
// Timers ------------------------------------------------------------------
// start timer for status bar
@ -142,6 +156,12 @@ void CClientSettingsDlg::OnSliderNetBufSiFactOut ( int value )
UpdateDisplay();
}
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
{
pClient->SetOpenChatOnNewMessage ( value == Qt::Checked );
UpdateDisplay();
}
void CClientSettingsDlg::UpdateDisplay()
{
// response time

View file

@ -71,4 +71,5 @@ public slots:
void OnSliderNetBuf ( int value );
void OnSliderNetBufSiFactIn ( int value );
void OnSliderNetBufSiFactOut ( int value );
void OnOpenChatOnNewMessageStateChanged ( int value );
};

View file

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>268</height>
<width>425</width>
<height>271</height>
</rect>
</property>
<property name="windowTitle" >
@ -19,21 +19,6 @@
<bool>true</bool>
</property>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="GroupBoxJitterBuffer" >
<property name="title" >
@ -735,24 +720,42 @@
<item>
<widget class="QGroupBox" name="GroupBoxMeasureResults" >
<property name="title" >
<string>Debug</string>
<string>Misc</string>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QCheckBox" name="cbOpenChatOnNewMessage" >
<property name="text" >
<string/>
</property>
</widget>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Open chat on new message</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>71</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
@ -843,19 +846,6 @@
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>

View file

@ -28,7 +28,8 @@
/* Implementation *************************************************************/
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent )
: pClient ( pNCliP ), QDialog ( parent ),
ClientSettingsDlg ( pNCliP, parent, Qt::WindowMinMaxButtonsHint )
ClientSettingsDlg ( pNCliP, parent, Qt::WindowMinMaxButtonsHint ),
ChatDlg ( parent, Qt::WindowMinMaxButtonsHint )
{
setupUi ( this );
@ -138,7 +139,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent )
// Settings menu ----------------------------------------------------------
pSettingsMenu = new QMenu ( "&Settings", this );
pSettingsMenu = new QMenu ( "&View", this );
pSettingsMenu->addAction ( tr ( "&Chat..." ), this,
SLOT ( OnOpenChatDialog() ) );
pSettingsMenu->addAction ( tr ( "&General Settings..." ), this,
SLOT ( OnOpenGeneralSettings() ) );
@ -187,8 +190,13 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent )
QObject::connect ( pClient,
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
this, SLOT ( OnConClientListMesReceived ( CVector<CChannelShortInfo> ) ) );
QObject::connect ( pClient,
SIGNAL ( ChatTextReceived ( QString ) ),
this, SLOT ( OnChatTextReceived ( QString ) ) );
QObject::connect ( MainMixerBoard, SIGNAL ( ChangeChanGain ( int, double ) ),
this, SLOT ( OnChangeChanGain ( int, double ) ) );
QObject::connect ( &ChatDlg, SIGNAL ( NewLocalInputText ( QString ) ),
this, SLOT ( OnNewLocalInputText ( QString ) ) );
// Timers ------------------------------------------------------------------
@ -207,8 +215,9 @@ CLlconClientDlg::~CLlconClientDlg()
void CLlconClientDlg::closeEvent ( QCloseEvent * Event )
{
// if settings dialog is open, close it
// if settings dialog or chat dialog is open, close it
ClientSettingsDlg.close();
ChatDlg.close();
// store IP address
pClient->strIPAddress = LineEditServerAddr->text();
@ -273,6 +282,27 @@ void CLlconClientDlg::OnOpenGeneralSettings()
ClientSettingsDlg.activateWindow();
}
void CLlconClientDlg::OnChatTextReceived ( QString strChatText )
{
ChatDlg.AddChatText ( strChatText );
// if requested, open window
if ( pClient->GetOpenChatOnNewMessage() )
{
ShowChatWindow();
}
}
void CLlconClientDlg::ShowChatWindow()
{
// open chat dialog
ChatDlg.show();
// make sure dialog is upfront and has focus
ChatDlg.raise();
ChatDlg.activateWindow();
}
void CLlconClientDlg::OnFaderTagTextChanged ( const QString& strNewName )
{
// refresh internal name parameter
@ -318,7 +348,7 @@ void CLlconClientDlg::OnTimerSigMet()
void CLlconClientDlg::UpdateDisplay()
{
// show connection status in status bar
if ( pClient->IsConnected () && pClient->IsRunning () )
if ( pClient->IsConnected() && pClient->IsRunning() )
{
TextLabelStatus->setText ( tr ( "connected" ) );
}

View file

@ -38,6 +38,7 @@
#include "multicolorled.h"
#include "audiomixerboard.h"
#include "clientsettingsdlg.h"
#include "chatdlg.h"
#ifdef _WIN32
# include "../windows/moc/llconclientdlgbase.h"
#else
@ -72,6 +73,8 @@ public:
virtual ~CLlconClientDlg();
protected:
void ShowChatWindow();
CClient* pClient;
bool bConnected;
QTimer TimerSigMet;
@ -85,12 +88,14 @@ protected:
QMenuBar* pMenu;
CClientSettingsDlg ClientSettingsDlg;
CChatDlg ChatDlg;
public slots:
void OnConnectDisconBut();
void OnTimerSigMet();
void OnTimerStatus() { UpdateDisplay(); }
void OnOpenGeneralSettings();
void OnOpenChatDialog() { ShowChatWindow(); }
void OnSliderAudInFader ( int value ) { pClient->SetAudioInFader ( value ); }
void OnSliderAudReverb ( int value ) { pClient->SetReverbLevel ( value ); }
void OnRevSelL() { pClient->SetReverbOnLeftChan ( true ); }
@ -100,4 +105,7 @@ public slots:
void OnChangeChanGain ( int iId, double dGain )
{ pClient->SetRemoteChanGain ( iId, dGain ); }
void OnFaderTagTextChanged ( const QString& strNewName );
void OnChatTextReceived ( QString strChatText );
void OnNewLocalInputText ( QString strChatText )
{ pClient->SendTextMess ( strChatText ); }
};

View file

@ -603,10 +603,10 @@ void CProtocol::CreateChanNameMes ( const QString strName )
CreateAndSendMessage ( PROTMESSID_CHANNEL_NAME, vecData );
}
void CProtocol::CreateChatTextMes ( const QString strName )
void CProtocol::CreateChatTextMes ( const QString strChatText )
{
unsigned int iPos = 0; // init position pointer
const int iStrLen = strName.size(); // get string size
const int iStrLen = strChatText.size(); // get string size
// size of current list entry
const int iEntrLen = 2 /* str. size */ + iStrLen;
@ -622,7 +622,7 @@ void CProtocol::CreateChatTextMes ( const QString strName )
{
// byte-by-byte copying of the string data
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( strName[j].toAscii() ), 1 );
static_cast<uint32_t> ( strChatText[j].toAscii() ), 1 );
}
CreateAndSendMessage ( PROTMESSID_CHAT_TEXT, vecData );
@ -654,16 +654,16 @@ void CProtocol::EvaluateChatTextMes ( unsigned int iPos, const CVector<uint8_t>&
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// name string (n bytes)
QString strName = "";
QString strChatText = "";
for ( int j = 0; j < iStrLen; j++ )
{
// byte-by-byte copying of the string data
int iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
strName += QString ( (char*) &iData );
strChatText += QString ( (char*) &iData );
}
// invoke message action
emit ChatTextReceived ( strName );
emit ChatTextReceived ( strChatText );
}

View file

@ -71,7 +71,7 @@ public:
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact );
void CreateChanGainMes ( const int iChanID, const double dGain );
void CreateChanNameMes ( const QString strName );
void CreateChatTextMes ( const QString strName );
void CreateChatTextMes ( const QString strChatText );
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo );
@ -164,7 +164,7 @@ signals:
void ChangeNetwBlSiFact ( int iNewNetwBlSiFact );
void ChangeChanGain ( int iChanID, double dNewGain );
void ChangeChanName ( QString strName );
void ChatTextReceived ( QString strName );
void ChatTextReceived ( QString strChatText );
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ReqJittBufSize();
void ReqConnClientsList();

View file

@ -101,10 +101,10 @@ void CSettings::ReadIniFile ( const QString& sFileName )
pClient->SetNetwBufSizeFactIn ( iValue );
}
// network buffer size factor out
if ( GetNumericIniSet ( IniXMLDocument, "client", "netwbusifactout", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) )
// flag whether the chat window shall be opened on a new chat message
if ( GetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", bValue ) )
{
pClient->SetNetwBufSizeFactOut ( iValue );
pClient->SetOpenChatOnNewMessage ( bValue );
}
}
@ -145,6 +145,9 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// network buffer size factor out
SetNumericIniSet ( IniXMLDocument, "client", "netwbusifactout", pClient->GetNetwBufSizeFactOut() );
// flag whether the chat window shall be opened on a new chat message
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", pClient->GetOpenChatOnNewMessage() );
// prepare file name for storing initialization data in XML file
QString sCurFileName = sFileName;

View file

@ -303,6 +303,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\chatdlg.cpp"
>
</File>
<File
RelativePath="..\src\client.cpp"
>