some more connect dialog work

This commit is contained in:
Volker Fischer 2011-04-11 19:09:01 +00:00
parent 7619ed2591
commit da9af48062
7 changed files with 130 additions and 31 deletions

View file

@ -117,6 +117,10 @@ CClient::CClient ( const quint16 iPortNumber ) :
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect ( &ConnLessProtocol,
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ),
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) );
QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );

View file

@ -205,14 +205,17 @@ public:
void SetRemoteName() { Channel.SetRemoteName ( strName ); }
void SendTextMess ( const QString& strChatText )
void CreateChatTextMes ( const QString& strChatText )
{ Channel.CreateChatTextMes ( strChatText ); }
void SendPingMess()
{ Channel.CreatePingMes ( PreparePingMessage() ); };
void CreatePingMes()
{ Channel.CreatePingMes ( PreparePingMessage() ); }
void SendCLPingMess ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); };
void CreateCLPingMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }
void CreateCLReqServerListMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); }
int EstimatedOverallDelay ( const int iPingTimeMs );
@ -312,6 +315,8 @@ signals:
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ChatTextReceived ( QString strChatText );
void PingTimeReceived ( int iPingTime );
void CLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo );
void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime );
void Disconnected();
void Stopped();

View file

@ -26,9 +26,9 @@
/* Implementation *************************************************************/
CConnectDlg::CConnectDlg ( CClient* pNCliP, QWidget* parent,
Qt::WindowFlags f )
: QDialog ( parent, f ), pClient ( pNCliP )
CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
: QDialog ( parent, f ),
bServerListReceived ( false )
{
setupUi ( this );
@ -53,26 +53,69 @@ pListViewItem = new QTreeWidgetItem ( ListViewServers );
// timers
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
QObject::connect ( &TimerReRequestServList, SIGNAL ( timeout() ),
this, SLOT ( OnTimerReRequestServList() ) );
}
void CConnectDlg::showEvent ( QShowEvent* )
{
// reset flag (on opening the connect dialg, we always want to request a new
// updated server list per definition)
bServerListReceived = false;
// TODO get the IP address of the Master Server when the connect dialog is
// opened -> this seems to be the correct time to do it, use the
// "CClient::SetServerAddr" functionality (extract it to another place...)
// TEST
QString strNAddr = "llcon.dyndns.org:22122";
// only activate ping timer if window is actually shown
TimerPing.start ( PING_UPDATE_TIME_MS );
// get the IP address of the central server (using the ParseNetworAddress
// function) when the connect dialog is opened, this seems to be the correct
// time to do it
if ( LlconNetwUtil().ParseNetworkAddress ( strNAddr,
CentralServerAddress ) )
{
// send the request for the server list
emit ReqServerListQuery ( CentralServerAddress );
// start timer, if this message did not get any respond to retransmit
// the server list request message
TimerReRequestServList.start ( SERV_LIST_REQ_UPDATE_TIME_MS );
}
// TODO
// only activate ping timer if window is actually shown
//TimerPing.start ( PING_UPDATE_TIME_MS );
// UpdateDisplay();
}
void CConnectDlg::hideEvent ( QHideEvent* )
{
// if window is closed, stop timer for ping
// if window is closed, stop timers
TimerPing.stop();
TimerReRequestServList.stop();
}
void CConnectDlg::OnTimerReRequestServList()
{
// if the server list is not yet received, retransmit the request for the
// server list
if ( !bServerListReceived )
{
emit ReqServerListQuery ( CentralServerAddress );
}
}
void CConnectDlg::SetServerList ( const CVector<CServerInfo>& vecServerInfo )
{
// set flag
bServerListReceived = true;
// TODO
}
void CConnectDlg::OnTimerPing()
@ -81,7 +124,7 @@ void CConnectDlg::OnTimerPing()
// TEST
//QHostAddress test ( "127.0.0.1" );
//pClient->SendCLPingMess ( CHostAddress ( test, 22124 ) );
//emit CreateCLPingMes ( CHostAddress ( test, 22124 ) );
}

View file

@ -27,6 +27,7 @@
#include <qpushbutton.h>
#include <qwhatsthis.h>
#include <qtimer.h>
#include <qmutex.h>
#include "global.h"
#include "client.h"
#ifdef _WIN32
@ -40,24 +41,31 @@
#endif
/* Definitions ****************************************************************/
// defines the time interval at which the request server list message is re-
// transmitted until it is received
#define SERV_LIST_REQ_UPDATE_TIME_MS 2000 // ms
/* Classes ********************************************************************/
class CConnectDlg : public QDialog, private Ui_CConnectDlgBase
{
Q_OBJECT
public:
CConnectDlg ( CClient* pNCliP, QWidget* parent = 0, Qt::WindowFlags f = 0 );
CConnectDlg ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void AddPingTime ( QString strChatText );
void SetServerList ( const CVector<CServerInfo>& vecServerInfo );
void SetPingTimeResult ( CHostAddress& InetAddr, const int iPingTime );
protected:
virtual void showEvent ( QShowEvent* );
virtual void hideEvent ( QHideEvent* );
CClient* pClient;
QTimer TimerPing;
QTimer TimerPing;
QTimer TimerReRequestServList;
CHostAddress CentralServerAddress;
bool bServerListReceived;
// TEST
QTreeWidgetItem* pListViewItem;
@ -65,4 +73,8 @@ QTreeWidgetItem* pListViewItem;
public slots:
void OnTimerPing();
void OnTimerReRequestServList();
signals:
void ReqServerListQuery ( CHostAddress InetAddr );
};

View file

@ -46,7 +46,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
, Qt::WindowMinMaxButtonsHint
#endif
),
ConnectDlg ( pNCliP, parent
ConnectDlg ( parent
#ifdef _WIN32
// this somehow only works reliable on Windows
, Qt::WindowMinMaxButtonsHint
@ -421,6 +421,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ),
this, SLOT ( OnPingTimeResult ( int ) ) );
QObject::connect ( pClient,
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ),
this, SLOT ( OnCLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) );
QObject::connect ( pClient, SIGNAL ( CLPingTimeReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingTimeResult ( CHostAddress, int ) ) );
@ -439,6 +443,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
QObject::connect ( &ChatDlg, SIGNAL ( NewLocalInputText ( QString ) ),
this, SLOT ( OnNewLocalInputText ( QString ) ) );
QObject::connect ( &ConnectDlg, SIGNAL ( NewLocalInputText ( CHostAddress ) ),
this, SLOT ( OnReqServerListQuery ( CHostAddress ) ) );
// Timers ------------------------------------------------------------------
// start timer for status bar
@ -716,7 +723,7 @@ void CLlconClientDlg::OnTimerSigMet()
void CLlconClientDlg::OnTimerPing()
{
// send ping message to server
pClient->SendPingMess();
pClient->CreatePingMes();
}
void CLlconClientDlg::OnPingTimeResult ( int iPingTime )

View file

@ -107,28 +107,54 @@ protected:
public slots:
void OnConnectDisconBut();
void OnTimerSigMet();
void OnTimerStatus() { UpdateDisplay(); }
void OnTimerStatus()
{ UpdateDisplay(); }
void OnTimerPing();
void OnPingTimeResult ( int iPingTime );
void OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime );
void OnOpenGeneralSettings();
void OnOpenChatDialog() { ShowChatWindow(); }
void OnOpenChatDialog()
{ ShowChatWindow(); }
void OnSliderAudInFader ( int value );
void OnSliderAudReverb ( int value ) { pClient->SetReverbLevel ( value ); }
void OnRevSelL() { pClient->SetReverbOnLeftChan ( true ); }
void OnRevSelR() { pClient->SetReverbOnLeftChan ( false ); }
void OnSliderAudReverb ( int value )
{ pClient->SetReverbLevel ( value ); }
void OnRevSelL()
{ pClient->SetReverbOnLeftChan ( true ); }
void OnRevSelR()
{ pClient->SetReverbOnLeftChan ( false ); }
void OnConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void OnChangeChanGain ( int iId, double dGain )
{ pClient->SetRemoteChanGain ( iId, dGain ); }
void OnFaderTagTextChanged ( const QString& strNewName );
void OnChatTextReceived ( QString strChatText );
void OnChangeChanGain ( int iId, double dGain )
{ pClient->SetRemoteChanGain ( iId, dGain ); }
void OnNewLocalInputText ( QString strChatText )
{ pClient->SendTextMess ( strChatText ); }
{ pClient->CreateChatTextMes ( strChatText ); }
void OnReqServerListQuery ( CHostAddress InetAddr )
{ pClient->CreateCLReqServerListMes ( InetAddr ); }
void OnCLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo )
{ ConnectDlg.SetServerList ( vecServerInfo ); }
void OnLineEditServerAddrTextChanged ( const QString );
void OnLineEditServerAddrActivated ( int index );
void OnDisconnected();
void OnStopped();
void OnGUIDesignChanged() { SetGUIDesign ( pClient->GetGUIDesign() ); }
void OnGUIDesignChanged()
{ SetGUIDesign ( pClient->GetGUIDesign() ); }
void OnStereoCheckBoxChanged() { UpdateRevSelection(); }
void OnNumClientsChanged ( int iNewNumClients );
};

View file

@ -240,6 +240,8 @@ void CServerListManager::QueryServerList ( const CHostAddress& InetAddr )
/* Slave server functionality *************************************************/
void CServerListManager::OnTimerRegistering()
{
// we need the lock since the user might change the server properties at
// any time
QMutexLocker locker ( &Mutex );
if ( !bIsCentralServer && bEnabled )