bug fix: the command line argument "-c" did not work anymore

This commit is contained in:
Volker Fischer 2013-02-09 21:23:10 +00:00
parent e8e2e8f540
commit 43d3225936
2 changed files with 65 additions and 38 deletions

View File

@ -266,9 +266,8 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
if ( bNewConnectOnStartup ) if ( bNewConnectOnStartup )
{ {
// since the software starts up right now, the previous state was // since the software starts up right now, the previous state was
// "not connected" so that a call to "OnConnectDisconBut()" will // "not connected" so we start the connection
// start the connection ConnectDisconnect ( true, true );
OnConnectDisconBut();
} }
@ -743,57 +742,84 @@ void CLlconClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr
iNumClients ); iNumClients );
} }
void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart,
const bool bConnectOnStartup )
{ {
// start/stop client, set button text // start/stop client, set button text
if ( bDoStart ) if ( bDoStart )
{ {
// get the central server address string QString strSelectedAddress;
const QString strCurCentServAddr = bool bConnectStateOK = false; // init flag
SELECT_SERVER_ADDRESS ( pClient->GetUseDefaultCentralServerAddress(),
pClient->GetServerListCentralServerAddress() );
// init the connect dialog and execute it (modal dialog) // only show connection dialog if this is not a connection on startup
ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress ); if ( bConnectOnStartup )
ConnectDlg.exec();
// check if state is OK (e.g., no Cancel was pressed)
if ( ConnectDlg.GetStateOK() )
{ {
const QString strSelectedAddress = ConnectDlg.GetSelectedAddress(); // per definition use the last connection (first entry in the
// stored address list)
strSelectedAddress = pClient->vstrIPAddress[0];
// only store new host address in our data base if the address is // only if address is not empty, start the client
// not empty and it was not a server list item (only the addresses if ( !strSelectedAddress.isEmpty() )
// typed in manually are stored by definition)
if ( !strSelectedAddress.isEmpty() &&
!ConnectDlg.GetServerListItemWasChosen() )
{ {
CVector<QString> vstrTempList ( MAX_NUM_SERVER_ADDR_ITEMS, "" ); bConnectStateOK = true;
}
}
else
{
// get the central server address string
const QString strCurCentServAddr =
SELECT_SERVER_ADDRESS ( pClient->GetUseDefaultCentralServerAddress(),
pClient->GetServerListCentralServerAddress() );
// store the new address in the current server storage list at // init the connect dialog and execute it (modal dialog)
// the top, make sure we do not have more than allowed stored ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress );
// servers ConnectDlg.exec();
vstrTempList[0] = strSelectedAddress;
int iTempListCnt = 1;
for ( int iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ ) // check if state is OK (e.g., no Cancel was pressed)
if ( ConnectDlg.GetStateOK() )
{
strSelectedAddress = ConnectDlg.GetSelectedAddress();
// only store new host address in our data base if the address is
// not empty and it was not a server list item (only the addresses
// typed in manually are stored by definition)
if ( !strSelectedAddress.isEmpty() &&
!ConnectDlg.GetServerListItemWasChosen() )
{ {
// only add old server address if it is not the same as the CVector<QString> vstrTempList ( MAX_NUM_SERVER_ADDR_ITEMS, "" );
// selected one
if ( ( pClient->vstrIPAddress[iIdx].compare ( strSelectedAddress ) ) &&
( iTempListCnt < MAX_NUM_SERVER_ADDR_ITEMS ) )
{
vstrTempList[iTempListCnt] =
pClient->vstrIPAddress[iIdx];
iTempListCnt++; // store the new address in the current server storage list at
// the top, make sure we do not have more than allowed stored
// servers
vstrTempList[0] = strSelectedAddress;
int iTempListCnt = 1;
for ( int iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ )
{
// only add old server address if it is not the same as the
// selected one
if ( ( pClient->vstrIPAddress[iIdx].compare ( strSelectedAddress ) ) &&
( iTempListCnt < MAX_NUM_SERVER_ADDR_ITEMS ) )
{
vstrTempList[iTempListCnt] =
pClient->vstrIPAddress[iIdx];
iTempListCnt++;
}
} }
// copy new generated list to client
pClient->vstrIPAddress = vstrTempList;
} }
// copy new generated list to client // everything was ok with the connection dialog, set flag
pClient->vstrIPAddress = vstrTempList; bConnectStateOK = true;
} }
}
// only start connection action if the connection state is ok
if ( bConnectStateOK )
{
// set address and check if address is valid // set address and check if address is valid
if ( pClient->SetServerAddr ( strSelectedAddress ) ) if ( pClient->SetServerAddr ( strSelectedAddress ) )
{ {

View File

@ -82,7 +82,8 @@ protected:
void ShowChatWindow(); void ShowChatWindow();
void UpdateAudioFaderSlider(); void UpdateAudioFaderSlider();
void UpdateRevSelection(); void UpdateRevSelection();
void ConnectDisconnect ( const bool bDoStart ); void ConnectDisconnect ( const bool bDoStart,
const bool bConnectOnStartup = false );
CClient* pClient; CClient* pClient;
CSettings* pSettings; CSettings* pSettings;