Exemplo n.º 1
0
tResult cJuryModule::Init()
{
    // connect the widgets and methods
    connect(m_pWidget->m_btnFileSelection, SIGNAL(released()), this, SLOT(OnManeuverListButton()));
    connect(m_pWidget->m_btnFileSelectionDescr, SIGNAL(released()), this, SLOT(OnDescriptionFileButton()));
    connect(m_pWidget->m_edtManeuverFile, SIGNAL(returnPressed()), this, SLOT(OnManeuverListSelected()));
    connect(m_pWidget->m_edtManeuverFile, SIGNAL(editingFinished()), this, SLOT(OnManeuverListSelected()));
    connect(m_pWidget->m_btnEmergencyStop, SIGNAL(released()), this, SLOT(OnEmergencyStop()));
    connect(m_pWidget->m_btnStart, SIGNAL(released()), this, SLOT(OnStart()));
    connect(m_pWidget->m_btnStop, SIGNAL(released()), this, SLOT(OnStop()));
    connect(m_pWidget->m_btnRequest, SIGNAL(released()), this, SLOT(OnRequestReady()));
    connect(m_pWidget->m_btnConnectDisconnect, SIGNAL(released()), this, SLOT(OnConnectDisconnect()));
    connect(m_pWidget->m_btnManeuverlist, SIGNAL(released()), this, SLOT(SendManeuverList()));
    connect(this, SIGNAL(SetDriverState(int, int)), this, SLOT(OnDriverState(int, int)));    
    connect(this, SIGNAL(SetLogText(QString)), this, SLOT(OnAppendText(QString)));
    connect(this, SIGNAL(SetConnectionState()), this, SLOT(OnConnectionStateChange()));
    connect(this, SIGNAL(SetControlState()), this, SLOT(OnControlState()));
    connect(m_pWidget->m_comboSector, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboSectionBoxChanged(int)));
    connect(m_pWidget->m_comboManeuver, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboActionBoxChanged(int)));
    connect(m_pWidget->m_cbxLocalHost, SIGNAL(stateChanged(int)), this, SLOT(OnLocalhostCheckChanged(int)));
    connect(m_pWidget->m_btnOpenTerminal, SIGNAL(released()), this, SLOT(OnOpenTerminalProcess()));
    connect(&m_oTerminalProcess, SIGNAL(started()), this, SLOT(OnProcessStarted()));
    connect(&m_oTerminalProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(OnProcessFinished(int,QProcess::ExitStatus)));
    connect(&m_oTerminalProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(OnProcessError(QProcess::ProcessError)));

    // set the connection and control state
    SetConnectionState();
    SetControlState();
    
    RETURN_NOERROR;
}
Exemplo n.º 2
0
nsresult NrIceCtx::StartChecks() {
  int r;

  if (policy_ == ICE_POLICY_NONE) {
    MOZ_MTLOG(ML_ERROR, "Couldn't start peer checks because policy == none");
    SetConnectionState(ICE_CTX_FAILED);
    return NS_ERROR_FAILURE;
  }
  r=nr_ice_peer_ctx_pair_candidates(peer_);
  if (r) {
    MOZ_MTLOG(ML_ERROR, "Couldn't pair candidates on "
              << name_ << "'");
    SetConnectionState(ICE_CTX_FAILED);
    return NS_ERROR_FAILURE;
  }

  r = nr_ice_peer_ctx_start_checks2(peer_,1);
  if (r) {
    if (r == R_NOT_FOUND) {
      MOZ_MTLOG(ML_ERROR, "Couldn't start peer checks on "
                << name_ << "' assuming trickle ICE");
    } else {
      MOZ_MTLOG(ML_ERROR, "Couldn't start peer checks on "
                << name_ << "'");
      SetConnectionState(ICE_CTX_FAILED);
      return NS_ERROR_FAILURE;
    }
  }

  return NS_OK;
}
Exemplo n.º 3
0
void CServerSocket::OnConnect(int nErrorCode) {
    CAsyncSocketEx::OnConnect(nErrorCode); // deadlake PROXYSUPPORT - changed to AsyncSocketEx
    switch (nErrorCode) {
    case 0: {
        if (cur_server->HasDynIP()) {
            SOCKADDR_IN sockAddr = {0};
            int nSockAddrLen = sizeof(sockAddr);
            GetPeerName((SOCKADDR*)&sockAddr, &nSockAddrLen);
            cur_server->SetIP(sockAddr.sin_addr.S_un.S_addr);
            CServer* pServer = theApp.serverlist->GetServerByAddress(cur_server->GetAddress(),cur_server->GetPort());
            if (pServer)
                pServer->SetIP(sockAddr.sin_addr.S_un.S_addr);
        }
        SetConnectionState(CS_WAITFORLOGIN);
        break;
    }
    case WSAEADDRNOTAVAIL:
    case WSAECONNREFUSED:
    //case WSAENETUNREACH:	// let this error default to 'fatal error' as it does not inrease the server's failed count
    case WSAETIMEDOUT:
    case WSAEADDRINUSE:
        if (thePrefs.GetVerbose())
            DebugLogError(_T("Failed to connect to server %s; %s"), cur_server->GetAddress(), GetErrorMessage(nErrorCode, 1));
        m_bIsDeleting = true;
        SetConnectionState(CS_SERVERDEAD);
        serverconnect->DestroySocket(this);
        return;
//==> remove PROXY [shadow2004]
#if defined(PROXY)
    // deadlake PROXYSUPPORT
    case WSAECONNABORTED:
        if (m_ProxyConnectFailed)
        {
            if (thePrefs.GetVerbose())
                DebugLogError(_T("Failed to connect to server %s; %s"), cur_server->GetAddress(), GetErrorMessage(nErrorCode, 1));
            m_ProxyConnectFailed = false;
            m_bIsDeleting = true;
            SetConnectionState(CS_SERVERDEAD);
            serverconnect->DestroySocket(this);
            return;
        }
#endif //PROXY
//<== remove PROXY [shadow2004]
    default:
        if (thePrefs.GetVerbose())
            DebugLogError(_T("Failed to connect to server %s; %s"), cur_server->GetAddress(), GetErrorMessage(nErrorCode, 1));
        m_bIsDeleting = true;
        SetConnectionState(CS_FATALERROR);
        serverconnect->DestroySocket(this);
        return;
    }
}
Exemplo n.º 4
0
void CServerSocket::OnClose(int nErrorCode) {
    CEMSocket::OnClose(0);
    if (connectionstate == CS_WAITFORLOGIN) {
        SetConnectionState(CS_SERVERFULL);
    }
    else if (connectionstate == CS_CONNECTED) {
        SetConnectionState(CS_DISCONNECTED);
    }
    else {
        SetConnectionState(CS_NOTCONNECTED);
    }
    serverconnect->DestroySocket(this);
}
Exemplo n.º 5
0
void CServerSocket::OnConnect(int nErrorCode)
{
	//Xman
	// MAella -QOS-
	/*
	CAsyncSocketEx::OnConnect(nErrorCode);
	*/
	CEMSocket::OnConnect(nErrorCode);
	//Xman end

	switch (nErrorCode)
	{
		case 0:
			SetConnectionState(CS_WAITFORLOGIN);
			break;

		case WSAEADDRNOTAVAIL:
		case WSAECONNREFUSED:
		//case WSAENETUNREACH:	// let this error default to 'fatal error' as it does not increase the server's failed count
		case WSAETIMEDOUT:
		case WSAEADDRINUSE:
			if (thePrefs.GetVerbose())
				DebugLogError(_T("Failed to connect to server %s; %s"), cur_server->GetAddress(), GetFullErrorMessage(nErrorCode));
			m_bIsDeleting = true;
			SetConnectionState(CS_SERVERDEAD);
			serverconnect->DestroySocket(this);
			return;

		case WSAECONNABORTED:
			if (m_bProxyConnectFailed)
			{
				if (thePrefs.GetVerbose())
					DebugLogError(_T("Failed to connect to server %s; %s"), cur_server->GetAddress(), GetFullErrorMessage(nErrorCode));
				m_bProxyConnectFailed = false;
				m_bIsDeleting = true;
				SetConnectionState(CS_SERVERDEAD);
				serverconnect->DestroySocket(this);
				return;
			}
			/* fall through */
		default:
			if (thePrefs.GetVerbose())
				DebugLogError(_T("Failed to connect to server %s; %s"), cur_server->GetAddress(), GetFullErrorMessage(nErrorCode));
			m_bIsDeleting = true;
			SetConnectionState(CS_FATALERROR);
			serverconnect->DestroySocket(this);
			return;
	}
}
bool AOnlineBeaconClient::InitClient(FURL& URL)
{
	bool bSuccess = false;

	if(URL.Valid)
	{
		if (InitBase() && NetDriver)
		{
			FString Error;
			if (NetDriver->InitConnect(this, URL, Error))
			{
				BeaconConnection = NetDriver->ServerConnection;

				// Kick off the connection handshake
				if (BeaconConnection->StatelessConnectComponent.IsValid())
				{
					BeaconConnection->StatelessConnectComponent.Pin()->SendInitialConnect();
				}

				SetConnectionState(EBeaconConnectionState::Pending);

				NetDriver->SetWorld(GetWorld());
				NetDriver->Notify = this;
				NetDriver->InitialConnectTimeout = BeaconConnectionInitialTimeout;
				NetDriver->ConnectionTimeout = BeaconConnectionTimeout;

				// Send initial message.
				uint8 IsLittleEndian = uint8(PLATFORM_LITTLE_ENDIAN);
				check(IsLittleEndian == !!IsLittleEndian); // should only be one or zero

				uint32 LocalNetworkVersion = FNetworkVersion::GetLocalNetworkVersion();
				
				FNetControlMessage<NMT_Hello>::Send(NetDriver->ServerConnection, IsLittleEndian, LocalNetworkVersion);
				NetDriver->ServerConnection->FlushNet();

				bSuccess = true;
			}
			else
			{
				// error initializing the network stack...
				UE_LOG(LogBeacon, Log, TEXT("AOnlineBeaconClient::InitClient failed"));
				SetConnectionState(EBeaconConnectionState::Invalid);
				OnFailure();
			}
		}
	}

	return bSuccess;
}
Exemplo n.º 7
0
void AOnlineBeaconClient::OnFailure()
{
	UE_LOG(LogBeacon, Verbose, TEXT("Client beacon (%s) connection failure, handling connection timeout."), *GetName());
	SetConnectionState(EBeaconConnectionState::Invalid);
	HostConnectionFailure.ExecuteIfBound();
	Super::OnFailure();
}
Exemplo n.º 8
0
CServerBrowser::CServerBrowser( CGUI_Impl * pGUI )
{
	// Store the gui pointer
	m_pGUI = pGUI;

	// Reset
	m_ulLastRefreshTime = 0;
	m_strServerPassword.clear ();
	m_iTotalServers = 0;
	m_iTotalPlayers = 0;
	m_iAvailableSlots = 0;

	// Create the masterlist instance
	m_pMasterList = new CMasterList( Event_MasterListQueryHandler );

	// Create the server query instance
	m_pServerQuery = new CServerQuery;

	// Create the server password instance
	m_pServerPassword = new CServerPassword ( pGUI );
	m_pServerPassword->SetSubmitHandler ( ServerPasswordHandler, this );

	// Reset the connection state
	SetConnectionState( CONNECTION_STATE_NONE );
}
Exemplo n.º 9
0
void CServerBrowser::SetDisconnectReason( bool bDisconnect, const char * szReason, ... )
{
	// Should we disconnect from the network?
	if( bDisconnect )
	{
		// Stop multiplayer
		pCore->StopMultiplayer();

		// Start multiplayer
		pCore->StartMultiplayer();
	}

	// Get the arguments
	char szBuffer[ MAX_MESSAGE_LEN ];
	va_list args;
	va_start( args, szReason );
	vsnprintf( szBuffer, MAX_MESSAGE_LEN, szReason, args );
	va_end( args );

	// Show the message box
	SetMessageBox ( "Disconnected from the server", szReason );

	// Set the connection state
	SetConnectionState( CONNECTION_STATE_FAILED );

	// Set the failed time
	m_ulFailedTime = SharedUtility::GetTime();

	// Disconnect from the network
	if( bDisconnect )
		pCore->GetNetworkModule()->Disconnect();
}
Exemplo n.º 10
0
nsresult NrIceCtx::StartGathering(bool default_route_only, bool proxy_only) {
  ASSERT_ON_THREAD(sts_target_);
  SetGatheringState(ICE_CTX_GATHER_STARTED);

  if (default_route_only) {
    nr_ice_ctx_add_flags(ctx_, NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS);
  } else {
    nr_ice_ctx_remove_flags(ctx_, NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS);
  }

  if (proxy_only) {
    nr_ice_ctx_add_flags(ctx_, NR_ICE_CTX_FLAGS_ONLY_PROXY);
  } else {
    nr_ice_ctx_remove_flags(ctx_, NR_ICE_CTX_FLAGS_ONLY_PROXY);
  }

  // This might start gathering for the first time, or again after
  // renegotiation, or might do nothing at all if gathering has already
  // finished.
  int r = nr_ice_gather(ctx_, &NrIceCtx::gather_cb, this);

  if (!r) {
    SetGatheringState(ICE_CTX_GATHER_COMPLETE);
  } else if (r != R_WOULDBLOCK) {
    MOZ_MTLOG(ML_ERROR, "Couldn't gather ICE candidates for '"
                        << name_ << "', error=" << r);
    SetConnectionState(ICE_CTX_FAILED);
    return NS_ERROR_FAILURE;
  }

  return NS_OK;
}
Exemplo n.º 11
0
void CServerBrowser::ProcessConnection( void )
{
	// Attempt to connect to the server
	eNetworkResponse response = pCore->GetNetworkModule()->Connect( m_strServerIP, m_iServerPort, m_strServerPassword );

	// Get the response string
	String strMessage( "An unknown error occurred." );
	switch( response )
	{
	case NETWORK_RESPONSE_SUCCESS: strMessage.Format( "Joining %s:%d...", m_strServerIP.Get(), m_iServerPort ); break;
	case NETWORK_RESPONSE_INVALID_PARAM: strMessage.Set( "An internal error occurred" ); break;
	case NETWORK_RESPONSE_CANT_RESOLVE_DOMAIN: strMessage.Set( "Can't resolve domain name!" ); break;
	case NETWORK_RESPONSE_ALREADY_CONNECTED: strMessage.Set( "You're already connect to a server." ); break;
	case NETWORK_RESPONSE_ALREADY_CONNECTING: strMessage.Set( "A connection attempt is already in progress!" ); break;
	case NETWORK_RESPONSE_SECURITY_FAILED: strMessage.Set( "Security initialisation failed!" ); break;
	case NETWORK_RESPONSE_NO_HOST_SET: strMessage.Set( "An internal error occurred." ); break;
	}

	// Show the message box
	SetMessageBox ( ((int)response == 0 ? "Connecting" : "Failed to connect"), strMessage.Get () );

	// Did we fail to connect?
	if( (int)response > 0 )
	{
		// Set the connection state to failed
		SetConnectionState( CONNECTION_STATE_FAILED );

		// Set the failed time
		m_ulFailedTime = SharedUtility::GetTime();
	}
}
Exemplo n.º 12
0
void AOnlineBeaconClient::OnNetCleanup(UNetConnection* Connection)
{
	ensure(Connection == BeaconConnection);
	SetConnectionState(EBeaconConnectionState::Closed);

	AOnlineBeaconHostObject* BeaconHostObject = GetBeaconOwner();
	if (BeaconHostObject)
	{
		BeaconHostObject->NotifyClientDisconnected(this);
	}
}
Exemplo n.º 13
0
void CServerSocket::ConnectTo(CServer* server, bool bNoCrypt)
{
	if (cur_server){
		ASSERT(0);
		delete cur_server;
		cur_server = NULL;
	}

	uint16 nPort = 0;
	cur_server = new CServer(server);
	if ( !bNoCrypt && thePrefs.IsServerCryptLayerTCPRequested() && server->GetObfuscationPortTCP() != 0 && server->SupportsObfuscationTCP()){
		Log(GetResString(IDS_CONNECTINGTOOBFUSCATED), cur_server->GetListName(), cur_server->GetAddress(), cur_server->GetObfuscationPortTCP());
		nPort = cur_server->GetObfuscationPortTCP();
		SetConnectionEncryption(true, NULL, true);
	}
	else{
		Log(GetResString(IDS_CONNECTINGTO), cur_server->GetListName(), cur_server->GetAddress(), cur_server->GetPort());
		nPort = cur_server->GetPort();
		SetConnectionEncryption(false, NULL, true);
	}

	// IP-filter: We do not need to IP-filter any servers here, even dynIP-servers are not
	// needed to get filtered here.
	//	1.) Non dynIP-servers were already IP-filtered when they were added to the server
	//		list.
	//	2.) Whenever the IP-filter is updated all servers for which an IP is known (this
	//		includes also dynIP-servers for which we received already an IP) get filtered.
	//	3.)	dynIP-servers get filtered after their DN was resolved. For TCP-connections this
	//		is done in OnConnect. For outgoing UDP packets this is done when explicitly
	//		resolving the DN right before sending the UDP packet.
	//
	SetConnectionState(CS_CONNECTING);
	if (!Connect(CStringA(server->GetAddress()), nPort)){
		DWORD dwError = GetLastError();
		if (dwError != WSAEWOULDBLOCK){
			LogError(GetResString(IDS_ERR_CONNECTIONERROR), cur_server->GetListName(), cur_server->GetAddress(), nPort, GetFullErrorMessage(dwError));
			SetConnectionState(CS_FATALERROR);
			return;
		}
	}
}
Exemplo n.º 14
0
void CServerBrowser::StartConnection ( void )
{
	// Are we already connected to a server?
	if( pCore->GetNetworkModule() && pCore->GetNetworkModule()->IsConnected() )
	{
		// Disconnect from the server
		pCore->GetNetworkModule()->Disconnect();

		// Stop multiplayer
		pCore->StopMultiplayer ();

		// Set the connection state
		SetConnectionState( CONNECTION_STATE_CONNECTING );

		// Start multiplayer
		pCore->StartMultiplayer ();

		// Connect!
		ProcessConnection ();
	}

	// Is the game not yet loaded?
	if( !pCore->IsGameLoaded() )
	{
		// Set the connection state
		SetConnectionState( CONNECTION_STATE_WAITING_FOR_GAME );

		// Show the message box
		SetMessageBox ( "Connecting", "Waiting for game to load..." );
	}
	else
	{
		// Move to the next step
		m_connectionState = CONNECTION_STATE_CONNECTING;

		// Connect!
		ProcessConnection ();
	}
}
Exemplo n.º 15
0
void AOnlineBeaconClient::DestroyBeacon()
{
	SetConnectionState(EBeaconConnectionState::Closed);

	UWorld* World = GetWorld();
	if (World)
	{
		// Fail safe for connection to server but no client connection RPC
		GetWorldTimerManager().ClearTimer(TimerHandle_OnFailure);
	}

	Super::DestroyBeacon();
}
Exemplo n.º 16
0
nsresult NrIceCtx::StartGathering() {
  MOZ_ASSERT(ctx_->state == ICE_CTX_INIT);
  if (ctx_->state != ICE_CTX_INIT) {
    MOZ_MTLOG(ML_ERROR, "ICE ctx in the wrong state for gathering: '"
              << name_ << "'");
    SetConnectionState(ICE_CTX_FAILED);
    return NS_ERROR_FAILURE;
  }

  int r = nr_ice_initialize(ctx_, &NrIceCtx::initialized_cb,
                            this);

  if (r && r != R_WOULDBLOCK) {
      MOZ_MTLOG(ML_ERROR, "Couldn't gather ICE candidates for '"
                << name_ << "'");
      SetConnectionState(ICE_CTX_FAILED);
      return NS_ERROR_FAILURE;
  }

  SetGatheringState(ICE_CTX_GATHER_STARTED);

  return NS_OK;
}
Exemplo n.º 17
0
void CServerSocket::ConnectToServer(CServer* server) {
    if (cur_server) {
        ASSERT(0);
        delete cur_server;
        cur_server = NULL;
    }

    cur_server = new CServer(server);
    Log(GetResString(IDS_CONNECTINGTO), cur_server->GetListName(), cur_server->GetFullIP(), cur_server->GetPort());

//==> remove PROXY [shadow2004]
#if defined(PROXY)
    if (thePrefs.IsProxyASCWOP() )
    {
        if (thePrefs.GetProxy().UseProxy == true)
        {
            thePrefs.SetProxyASCWOP(true);
            thePrefs.SetUseProxy(false);
            AddLogLine(false, GetResString(IDS_ASCWOP_PROXYSUPPORT) + GetResString(IDS_DISABLED));
        }
        else
            thePrefs.SetProxyASCWOP(false);
    }
#endif //PROXY
//<== remove PROXY [shadow2004]

    SetConnectionState(CS_CONNECTING);
    if (!Connect(server->GetAddress(),server->GetPort())) {
        DWORD dwError = GetLastError();
        if (dwError != WSAEWOULDBLOCK) {
            LogError(GetResString(IDS_ERR_CONNECTIONERROR), cur_server->GetListName(), cur_server->GetFullIP(), cur_server->GetPort(), GetErrorMessage(dwError, 1));
            SetConnectionState(CS_FATALERROR);
            return;
        }
    }
    SetConnectionState(CS_CONNECTING);
}
void AOnlineBeaconClient::ClientOnConnected_Implementation()
{
	SetConnectionState(EBeaconConnectionState::Open);
	BeaconConnection->State = USOCK_Open;

	Role = ROLE_Authority;
	SetReplicates(true);
	SetAutonomousProxy(true);

	// Fail safe for connection to server but no client connection RPC
	GetWorldTimerManager().ClearTimer(TimerHandle_OnFailure);

	// Call the overloaded function for this client class
	OnConnected();
}
Exemplo n.º 19
0
nsresult NrIceCtx::StartGathering() {
  ASSERT_ON_THREAD(sts_target_);
  SetGatheringState(ICE_CTX_GATHER_STARTED);
  // This might start gathering for the first time, or again after
  // renegotiation, or might do nothing at all if gathering has already
  // finished.
  int r = nr_ice_gather(ctx_, &NrIceCtx::gather_cb, this);

  if (!r) {
    SetGatheringState(ICE_CTX_GATHER_COMPLETE);
  } else if (r != R_WOULDBLOCK) {
    MOZ_MTLOG(ML_ERROR, "Couldn't gather ICE candidates for '"
                        << name_ << "', error=" << r);
    SetConnectionState(ICE_CTX_FAILED);
    return NS_ERROR_FAILURE;
  }

  return NS_OK;
}
Exemplo n.º 20
0
void AOnlineBeaconClient::ClientOnConnected_Implementation()
{
	SetConnectionState(EBeaconConnectionState::Open);

	Role = ROLE_Authority;
	SetReplicates(true);
	SetAutonomousProxy(true);

	// Fail safe for connection to server but no client connection RPC
	GetWorldTimerManager().ClearTimer(TimerHandle_OnFailure);

	if (NetDriver)
	{
		// Increase timeout while we are connected
		NetDriver->InitialConnectTimeout = BeaconConnectionTimeout;
		NetDriver->ConnectionTimeout = BeaconConnectionTimeout;
	}

	// Call the overloaded function for this client class
	OnConnected();
}
Exemplo n.º 21
0
BOOL CServerSocket::OnHostNameResolved(const SOCKADDR_IN *pSockAddr)
{
	// If we are connecting to a dynIP-server by DN, we will get this callback after the
	// DNS query finished.
	//
	if (cur_server->HasDynIP())
	{
		// Update the IP of this dynIP-server
		//
		cur_server->SetIP(pSockAddr->sin_addr.S_un.S_addr);
		CServer* pServer = theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort());
		if (pServer) {
			pServer->SetIP(pSockAddr->sin_addr.S_un.S_addr);
			// If we already have entries in the server list (dynIP-servers without a DN)
			// with the same IP as this dynIP-server, remove the duplicates.
			theApp.serverlist->RemoveDuplicatesByIP(pServer);
		}
		DEBUG_ONLY( DebugLog(_T("Resolved DN for server '%s': IP=%s"), cur_server->GetAddress(), ipstr(cur_server->GetIP())) );

		// As this is a dynIP-server, we need to check the IP against the IP-filter
		// and eventually disconnect and delete that server.
		//
		if (thePrefs.GetFilterServerByIP() && theApp.ipfilter->IsFiltered(cur_server->GetIP())) {
			if (thePrefs.GetLogFilteredIPs())
				AddDebugLogLine(false, _T("IPFilter(TCP/DNSResolve): Filtered server \"%s\" (IP=%s) - IP filter (%s)"), pServer ? pServer->GetAddress() : cur_server->GetAddress(), ipstr(cur_server->GetIP()), theApp.ipfilter->GetLastHit());
			if (pServer)
				theApp.emuledlg->serverwnd->serverlistctrl.RemoveServer(pServer);
			m_bIsDeleting = true;
			SetConnectionState(CS_ERROR);
			serverconnect->DestroySocket(this);
			return FALSE;	// Do *NOT* connect to this server
		}
		//zz_fly :: support dynamic ip servers :: DolphinX :: Start
		if (pServer)
			pServer->ResetIP2Country(); //EastShare - added by AndCycle, IP to Country
		//zz_fly :: End
	}
	return TRUE; // Connect to this server
}
Exemplo n.º 22
0
void CServerBrowser::Pulse( void )
{
	// Pulse the current server list
	if ( m_pServerList [ GetCurrentServerBrowserType () ] )
		m_pServerList [ GetCurrentServerBrowserType () ]->Pulse ();

	// Pulse the connection state
	if( m_connectionState == CONNECTION_STATE_WAITING_FOR_GAME )
	{
		// Is the game loaded now?
		if( pCore->IsGameLoaded() )
		{
			// Move to the next step
			m_connectionState = CONNECTION_STATE_CONNECTING;

			// Connect!
			ProcessConnection();
		}
	}
	else if( m_connectionState == CONNECTION_STATE_FAILED )
	{
		// Has 3 seconds passed?
		if( (SharedUtility::GetTime() - m_ulFailedTime) >= 3000 )
		{
			// Hide the message box
			m_pMessageBox->SetVisible ( false );

			// Show the main menu
			pCore->GetGUI()->GetMainMenu()->SetVisible( true );

			// Reset the connection state
			SetConnectionState( CONNECTION_STATE_NONE );

			// Reset the failed time
			m_ulFailedTime = 0;
		}
	}
}
Exemplo n.º 23
0
bool CServerSocket::ProcessPacket(char* packet, uint32 size, uint8 opcode) {
    try {
        switch(opcode) {
        case OP_SERVERMESSAGE: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_ServerMessage\n"));

            CServer* pServer = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(),cur_server->GetPort()) : NULL;
            CSafeMemFile data((const BYTE*)packet, size);
            CString strMessages(data.ReadString(pServer ? pServer->GetUnicodeSupport() : false));

            if (thePrefs.GetDebugServerTCPLevel() > 0) {
                UINT uAddData = data.GetLength() - data.GetPosition();
                if (uAddData > 0) {
                    Debug(_T("*** NOTE: OP_ServerMessage: ***AddData: %u bytes\n"), uAddData);
                    DebugHexDump((uint8*)packet + data.GetPosition(), uAddData);
                }
            }

            // 16.40 servers do not send separate OP_SERVERMESSAGE packets for each line;
            // instead of this they are sending all text lines with one OP_SERVERMESSAGE packet.
            int iPos = 0;
            CString message = strMessages.Tokenize(_T("\r\n"), iPos);
            while (!message.IsEmpty())
            {
                bool bOutputMessage = true;
                if (_tcsnicmp(message, _T("server version"), 14) == 0) {
                    CString strVer = message.Mid(14);
                    strVer.Trim();
                    strVer = strVer.Left(64); // truncate string to avoid misuse by servers in showing ads
                    if (pServer) {
                        pServer->SetVersion(strVer);
                        theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer(pServer);
                        theApp.emuledlg->serverwnd->UpdateMyInfo();
                    }
                    if (thePrefs.GetDebugServerTCPLevel() > 0)
                        Debug(_T("%s\n"), message);
                }
                else if (_tcsncmp(message, _T("ERROR"), 5) == 0) {
                    LogError(LOG_STATUSBAR, _T("%s %s (%s:%u) - %s"),
                             GetResString(IDS_ERROR),
                             pServer ? pServer->GetListName() : GetResString(IDS_PW_SERVER),
                             cur_server ? cur_server->GetAddress() : _T(""),
                             cur_server ? cur_server->GetPort() : 0, message.Mid(5).Trim(_T(" :")));
                    bOutputMessage = false;
                }
                else if (_tcsncmp(message, _T("WARNING"), 7) == 0) {
                    LogWarning(LOG_STATUSBAR, _T("%s %s (%s:%u) - %s"),
                               GetResString(IDS_WARNING),
                               pServer ? pServer->GetListName() : GetResString(IDS_PW_SERVER),
                               cur_server ? cur_server->GetAddress() : _T(""),
                               cur_server ? cur_server->GetPort() : 0, message.Mid(7).Trim(_T(" :")));
                    bOutputMessage = false;
                }

                if (message.Find(_T("[emDynIP: ")) != -1 && message.Find(_T("]")) != -1 && message.Find(_T("[emDynIP: ")) < message.Find(_T("]"))) {
                    CString dynip = message.Mid(message.Find(_T("[emDynIP: ")) + 10, message.Find(_T("]")) - (message.Find(_T("[emDynIP: ")) + 10));
                    dynip.Trim(_T(" "));
                    if (dynip.GetLength() && dynip.GetLength() < 51) {
                        if (pServer) {
                            pServer->SetDynIP(dynip);
                            if (cur_server)
                                cur_server->SetDynIP(dynip);
                            theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer(pServer);
                            theApp.emuledlg->serverwnd->UpdateMyInfo();
                        }
                    }
                }
                if (bOutputMessage)
                    theApp.emuledlg->AddServerMessageLine(message);

                message = strMessages.Tokenize(_T("\r\n"), iPos);
            }
            break;
        }
        case OP_IDCHANGE: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_IDChange\n"));
            if (size < sizeof(LoginAnswer_Struct)) {
                throw GetResString(IDS_ERR_BADSERVERREPLY);
            }
            LoginAnswer_Struct* la = (LoginAnswer_Struct*)packet;

            // save TCP flags in 'cur_server'
            ASSERT( cur_server );
            if (cur_server) {
                if (size >= sizeof(LoginAnswer_Struct)+4) {
                    DWORD dwFlags = *((uint32*)(packet + sizeof(LoginAnswer_Struct)));
                    if (thePrefs.GetDebugServerTCPLevel() > 0) {
                        CString strInfo;
                        strInfo.AppendFormat(_T("  TCP Flags=0x%08x"), dwFlags);
                        const DWORD dwKnownBits = SRV_TCPFLG_COMPRESSION | SRV_TCPFLG_NEWTAGS | SRV_TCPFLG_UNICODE;
                        if (dwFlags & ~dwKnownBits)
                            strInfo.AppendFormat(_T("  ***UnkBits=0x%08x"), dwFlags & ~dwKnownBits);
                        if (dwFlags & SRV_TCPFLG_COMPRESSION)
                            strInfo.AppendFormat(_T("  Compression=1"));
                        if (dwFlags & SRV_TCPFLG_NEWTAGS)
                            strInfo.AppendFormat(_T("  NewTags=1"));
                        if (dwFlags & SRV_TCPFLG_UNICODE)
                            strInfo.AppendFormat(_T("  Unicode=1"));
                        Debug(_T("%s\n"), strInfo);
                    }
                    cur_server->SetTCPFlags(dwFlags);
                }
                else
                    cur_server->SetTCPFlags(0);

                // copy TCP flags into the server in the server list
                CServer* pServer = theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort());
                if (pServer)
                    pServer->SetTCPFlags(cur_server->GetTCPFlags());
            }

            if (la->clientid == 0) {
                uint8 state = thePrefs.GetSmartIdState();
                if ( state > 0 ) {
                    state++;
                    if( state > 3 )
                        thePrefs.SetSmartIdState(0);
                    else
                        thePrefs.SetSmartIdState(state);
                }
                break;
            }
            if( thePrefs.GetSmartIdCheck() ) {
                if (!IsLowID(la->clientid))
                    thePrefs.SetSmartIdState(1);
                else {
                    uint8 state = thePrefs.GetSmartIdState();
                    if ( state > 0 ) {
                        state++;
                        if( state > 3 )
                            thePrefs.SetSmartIdState(0);
                        else
                            thePrefs.SetSmartIdState(state);
                        break;
                    }
                }
            }

//==>Lowid retry by SlugFiller [cyrex2001]
#ifdef LOWID
            if (thePrefs.GetLowIdRetried())
            {
                if (la->clientid < 16777216 )
                {
                    SetConnectionState(CS_ERROR);
                    AddLogLine(true,GetResString(IDS_LOWIDRETRYING),thePrefs.GetLowIdRetried());
                    thePrefs.SetLowIdRetried();
                    break;
                }
            }
#endif //Lowid retry
//<==Lowid retry [cyrex2001]
            // we need to know our client's HighID when sending our shared files (done indirectly on SetConnectionState)
            serverconnect->clientid = la->clientid;

            if (connectionstate != CS_CONNECTED) {
                SetConnectionState(CS_CONNECTED);
                theApp.OnlineSig();       // Added By Bouc7
            }
            serverconnect->SetClientID(la->clientid);
            AddLogLine(false, GetResString(IDS_NEWCLIENTID), la->clientid);
//==>Reask sourcen after ip change [cyrex2001]
#ifdef RSAIC_MAELLA
            theApp.CheckIDChange();
#endif //Reask sourcen after ip change
//<==Reask sourcen after ip change [cyrex2001]
            theApp.downloadqueue->ResetLocalServerRequests();
            break;
        }
        case OP_SEARCHRESULT: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_SearchResult\n"));
            CServer* cur_srv = (serverconnect) ? serverconnect->GetCurrentServer() : NULL;
            CServer* pServer = cur_srv ? theApp.serverlist->GetServerByAddress(cur_srv->GetAddress(), cur_srv->GetPort()) : NULL;
            bool bMoreResultsAvailable;
            uint16 uSearchResults = theApp.searchlist->ProcessSearchanswer(packet, size, true/*pServer ? pServer->GetUnicodeSupport() : false*/, cur_srv ? cur_srv->GetIP() : 0, cur_srv ? cur_srv->GetPort() : 0, &bMoreResultsAvailable);
            theApp.emuledlg->searchwnd->LocalSearchEnd(uSearchResults, bMoreResultsAvailable);
            break;
        }
        case OP_FOUNDSOURCES: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_FoundSources; Sources=%u  %s\n"), (UINT)(uchar)packet[16], DbgGetFileInfo((uchar*)packet));
            ASSERT( cur_server );
            if (cur_server)
            {
                CSafeMemFile sources((BYTE*)packet,size);
                uchar fileid[16];
                sources.ReadHash16(fileid);
                if (CPartFile* file = theApp.downloadqueue->GetFileByID(fileid))
                    file->AddSources(&sources,cur_server->GetIP(), cur_server->GetPort());
            }
            break;
        }
        case OP_SERVERSTATUS: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_ServerStatus\n"));
            // FIXME some statuspackets have a different size -> why? structur?
            if (size < 8)
                break;//throw "Invalid status packet";
            uint32 cur_user = PeekUInt32(packet);
            uint32 cur_files = PeekUInt32(packet+4);
            CServer* update = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()) : NULL;
            if (update) {
                update->SetUserCount(cur_user);
                update->SetFileCount(cur_files);
                theApp.emuledlg->ShowUserCount();
                theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer( update );
                theApp.emuledlg->serverwnd->UpdateMyInfo();
            }
            if (thePrefs.GetDebugServerTCPLevel() > 0) {
                if (size > 8) {
                    Debug(_T("*** NOTE: OP_ServerStatus: ***AddData: %u bytes\n"), size - 8);
                    DebugHexDump((uint8*)packet + 8, size - 8);
                }
            }
            break;
        }
        case OP_SERVERIDENT: {
            // OP_SERVERIDENT - this is sent by the server only if we send a OP_GETSERVERLIST
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_ServerIdent\n"));
            if (size<16+4+2+4) {
                if (thePrefs.GetVerbose())
                    DebugLogError(_T("%s"), GetResString(IDS_ERR_KNOWNSERVERINFOREC));
                break;// throw "Invalid server info received";
            }

            CServer* pServer = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(),cur_server->GetPort()) : NULL;
            CString strInfo;
            CSafeMemFile data((BYTE*)packet, size);

            uint8 aucHash[16];
            data.ReadHash16(aucHash);
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                strInfo.AppendFormat(_T("Hash=%s (%s)"), md4str(aucHash), DbgGetHashTypeString(aucHash));
            uint32 nServerIP = data.ReadUInt32();
            uint16 nServerPort = data.ReadUInt16();
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                strInfo.AppendFormat(_T("  IP=%s:%u"), ipstr(nServerIP), nServerPort);
            UINT nTags = data.ReadUInt32();
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                strInfo.AppendFormat(_T("  Tags=%u"), nTags);

            CString strName;
            CString strDescription;
            for (UINT i = 0; i < nTags; i++) {
                CTag tag(&data, pServer ? pServer->GetUnicodeSupport() : false);
                if (tag.GetNameID() == ST_SERVERNAME) {
                    if (tag.IsStr()) {
                        strName = tag.GetStr();
                        if (thePrefs.GetDebugServerTCPLevel() > 0)
                            strInfo.AppendFormat(_T("  Name=%s"), strName);
                    }
                }
                else if (tag.GetNameID() == ST_DESCRIPTION) {
                    if (tag.IsStr()) {
                        strDescription = tag.GetStr();
                        if (thePrefs.GetDebugServerTCPLevel() > 0)
                            strInfo.AppendFormat(_T("  Desc=%s"), strDescription);
                    }
                }
                else if (thePrefs.GetDebugServerTCPLevel() > 0)
                    strInfo.AppendFormat(_T("  ***UnkTag: 0x%02x=%u"), tag.GetNameID(), tag.GetInt());
            }
            if (thePrefs.GetDebugServerTCPLevel() > 0) {
                strInfo += _T('\n');
                Debug(_T("%s"), strInfo);

                UINT uAddData = data.GetLength() - data.GetPosition();
                if (uAddData > 0) {
                    Debug(_T("*** NOTE: OP_ServerIdent: ***AddData: %u bytes\n"), uAddData);
                    DebugHexDump((uint8*)packet + data.GetPosition(), uAddData);
                }
            }

            if (pServer) {
                pServer->SetListName(strName);
                pServer->SetDescription(strDescription);
                if (((uint32*)aucHash)[0] == 0x2A2A2A2A) {
                    const CString& rstrVersion = pServer->GetVersion();
                    if (!rstrVersion.IsEmpty())
                        pServer->SetVersion(_T("eFarm ") + rstrVersion);
                    else
                        pServer->SetVersion(_T("eFarm"));
                }
                theApp.emuledlg->ShowConnectionState();
                theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer(pServer);
                theApp.emuledlg->serverwnd->UpdateMyInfo();
            }
            break;
        }
        // tecxx 1609 2002 - add server's serverlist to own serverlist
        case OP_SERVERLIST: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_ServerList\n"));
            try {
                CSafeMemFile servers((BYTE*)packet,size);
                UINT count = servers.ReadUInt8();
                // check if packet is valid
                if (1 + count*(4+2) > size)
                    count = 0;
                int addcount = 0;
                while(count)
                {
                    uint32 ip = servers.ReadUInt32();
                    uint16 port = servers.ReadUInt16();
                    CServer* srv = new CServer(port, ipstr(ip));
                    srv->SetListName(srv->GetFullIP());
                    if (!theApp.emuledlg->serverwnd->serverlistctrl.AddServer(srv, true))
                        delete srv;
                    else
                        addcount++;
                    count--;
                }
                if (addcount)
                    AddLogLine(false, GetResString(IDS_NEWSERVERS), addcount);
                if (thePrefs.GetDebugServerTCPLevel() > 0) {
                    UINT uAddData = servers.GetLength() - servers.GetPosition();
                    if (uAddData > 0) {
                        Debug(_T("*** NOTE: OP_ServerList: ***AddData: %u bytes\n"), uAddData);
                        DebugHexDump((uint8*)packet + servers.GetPosition(), uAddData);
                    }
                }
            }
            catch(CFileException* error) {
                if (thePrefs.GetVerbose())
                    DebugLogError(_T("%s"), GetResString(IDS_ERR_BADSERVERLISTRECEIVED));
                error->Delete();
            }
            break;
        }
        case OP_CALLBACKREQUESTED: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_CallbackRequested\n"));
            if (size == 6)
            {
                uint32 dwIP = PeekUInt32(packet);

                if (theApp.ipfilter->IsFiltered(dwIP)) {
                    theStats.filteredclients++;
                    if (thePrefs.GetLogFilteredIPs())
                        AddDebugLogLine(false, _T("Ignored callback request (IP=%s) - IP filter (%s)"), ipstr(dwIP), theApp.ipfilter->GetLastHit());
                    break;
                }

                if (theApp.clientlist->IsBannedClient(dwIP)) {
                    if (thePrefs.GetLogBannedClients()) {
                        CUpDownClient* pClient = theApp.clientlist->FindClientByIP(dwIP);
                        AddDebugLogLine(false, _T("Ignored callback request from banned client %s; %s"), ipstr(dwIP), pClient->DbgGetClientInfo());
                    }
                    break;
                }

                uint16 nPort = PeekUInt16(packet+4);
                CUpDownClient* client = theApp.clientlist->FindClientByIP(dwIP,nPort);
                if (client)
                    client->TryToConnect();
                else
                {
                    client = new CUpDownClient(0,nPort,dwIP,0,0,true);
                    theApp.clientlist->AddClient(client);
                    client->TryToConnect();
                }
            }
            break;
        }
        case OP_CALLBACK_FAIL: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_Callback_Fail %s\n"), DbgGetHexDump((uint8*)packet, size));
            break;
        }
        case OP_REJECT: {
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("ServerMsg - OP_Reject %s\n"), DbgGetHexDump((uint8*)packet, size));
            // this could happen if we send a command with the wrong protocol (e.g. sending a compressed packet to
            // a server which does not support that protocol).
            if (thePrefs.GetVerbose())
                DebugLogError(_T("Server rejected last command"));
            break;
        }
        default:
            if (thePrefs.GetDebugServerTCPLevel() > 0)
                Debug(_T("***NOTE: ServerMsg - Unknown message; opcode=0x%02x  %s\n"), opcode, DbgGetHexDump((uint8*)packet, size));
            ;
        }

        return true;
    }
    catch(CFileException* error)
    {
        if (thePrefs.GetVerbose())
        {
            TCHAR szError[MAX_CFEXP_ERRORMSG];
            error->m_strFileName = _T("server packet");
            error->GetErrorMessage(szError, ARRSIZE(szError));
            DebugLogError(GetResString(IDS_ERR_PACKAGEHANDLING), szError);
        }
        error->Delete();
        ASSERT(0);
        if (opcode==OP_SEARCHRESULT || opcode==OP_FOUNDSOURCES)
            return true;
    }
    catch(CMemoryException* error)
    {
        if (thePrefs.GetVerbose())
            DebugLogError(GetResString(IDS_ERR_PACKAGEHANDLING), _T("CMemoryException"));
        error->Delete();
        ASSERT(0);
        if (opcode==OP_SEARCHRESULT || opcode==OP_FOUNDSOURCES)
            return true;
    }
    catch(CString error)
    {
        if (thePrefs.GetVerbose())
            DebugLogError(GetResString(IDS_ERR_PACKAGEHANDLING), error);
        ASSERT(0);
    }
    catch(...)
    {
        if (thePrefs.GetVerbose())
            DebugLogError(GetResString(IDS_ERR_PACKAGEHANDLING), _T("Unknown exception"));
        ASSERT(0);
    }

    SetConnectionState(CS_DISCONNECTED);
    return false;
}
Exemplo n.º 24
0
bool CServerSocket::ProcessPacket(const BYTE* packet, uint32 size, uint8 opcode)
{
	try
	{
		switch (opcode)
		{
			case OP_SERVERMESSAGE:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_ServerMessage\n"));

				CServer* pServer = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()) : NULL;
				CSafeMemFile data(packet, size);
				CString strMessages(data.ReadString(pServer ? pServer->GetUnicodeSupport() : false));

				if (thePrefs.GetDebugServerTCPLevel() > 0){
					UINT uAddData = (UINT)(data.GetLength() - data.GetPosition());
					if (uAddData > 0){
						Debug(_T("*** NOTE: OP_ServerMessage: ***AddData: %u bytes\n"), uAddData);
						DebugHexDump(packet + data.GetPosition(), uAddData);
					}
				}

				// 16.40 servers do not send separate OP_SERVERMESSAGE packets for each line;
				// instead of this they are sending all text lines with one OP_SERVERMESSAGE packet.
				int iPos = 0;
				CString message = strMessages.Tokenize(_T("\r\n"), iPos);
				while (!message.IsEmpty())
				{
					bool bOutputMessage = true;
					if (_tcsnicmp(message, _T("server version"), 14) == 0){
						CString strVer = message.Mid(14);
						strVer.Trim();
						strVer = strVer.Left(64); // truncate string to avoid misuse by servers in showing ads
						if (pServer){
							UINT nVerMaj, nVerMin;
							if (_stscanf(strVer, _T("%u.%u"), &nVerMaj, &nVerMin) == 2)
								strVer.Format(_T("%u.%02u"), nVerMaj, nVerMin);
							pServer->SetVersion(strVer);
							theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer(pServer);
							theApp.emuledlg->serverwnd->UpdateMyInfo();
						}
						if (thePrefs.GetDebugServerTCPLevel() > 0)
							Debug(_T("%s\n"), message);
					}
					else if (_tcsncmp(message, _T("ERROR"), 5) == 0){
						LogError(LOG_STATUSBAR, _T("%s %s (%s:%u) - %s"), 
							GetResString(IDS_ERROR),
							pServer ? pServer->GetListName() : GetResString(IDS_PW_SERVER), 
							cur_server ? cur_server->GetAddress() : _T(""), 
							cur_server ? cur_server->GetPort() : 0, message.Mid(5).Trim(_T(" :")));
						bOutputMessage = false;
					}
					else if (_tcsncmp(message, _T("WARNING"), 7) == 0){
						LogWarning(LOG_STATUSBAR, _T("%s %s (%s:%u) - %s"), 
							GetResString(IDS_WARNING),
							pServer ? pServer->GetListName() : GetResString(IDS_PW_SERVER), 
							cur_server ? cur_server->GetAddress() : _T(""),
							cur_server ? cur_server->GetPort() : 0, message.Mid(7).Trim(_T(" :")));
						bOutputMessage = false;
					}

					if (message.Find(_T("[emDynIP: ")) != -1 && message.Find(_T("]")) != -1 && message.Find(_T("[emDynIP: ")) < message.Find(_T("]"))){
						CString dynip = message.Mid(message.Find(_T("[emDynIP: ")) + 10, message.Find(_T("]")) - (message.Find(_T("[emDynIP: ")) + 10));
						dynip.Trim();
						if (dynip.GetLength() && dynip.GetLength() < 51){
							// Verify that we really received a DN.
							if (pServer && inet_addr(CStringA(dynip)) == INADDR_NONE){
								// Update the dynIP of this server, but do not reset it's IP
								// which we just determined during connecting.
								CString strOldDynIP = pServer->GetDynIP();
								pServer->SetDynIP(dynip);
								// If a dynIP-server changed its address or, if this is the
								// first time we get the dynIP-address for a server which we
								// already have as non-dynIP in our list, we need to remove
								// an already available server with the same 'dynIP:port'.
								if (strOldDynIP.CompareNoCase(pServer->GetDynIP()) != 0)
									theApp.serverlist->RemoveDuplicatesByAddress(pServer);
								if (cur_server)
									cur_server->SetDynIP(dynip);
								theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer(pServer);
								theApp.emuledlg->serverwnd->UpdateMyInfo();
							}
						}
					}

					if (bOutputMessage) {
						if (m_bStartNewMessageLog) {
							m_bStartNewMessageLog = false;
							theApp.emuledlg->AddServerMessageLine(LOG_INFO, _T(""));
							if (cur_server) {
								CString strMsg;
								if (IsObfusicating())
									strMsg.Format(_T("%s: ") + GetResString(IDS_CONNECTEDTOOBFUSCATED) + _T(" (%s:%u)"), CTime::GetCurrentTime().Format(thePrefs.GetDateTimeFormat4Log()), cur_server->GetListName(), cur_server->GetAddress(), cur_server->GetObfuscationPortTCP());
								else
									strMsg.Format(_T("%s: ") + GetResString(IDS_CONNECTEDTO) + _T(" (%s:%u)"), CTime::GetCurrentTime().Format(thePrefs.GetDateTimeFormat4Log()), cur_server->GetListName(), cur_server->GetAddress(), cur_server->GetPort());
								theApp.emuledlg->AddServerMessageLine(LOG_SUCCESS, strMsg);
							}
						}
						theApp.emuledlg->AddServerMessageLine(LOG_INFO, message);
					}

					message = strMessages.Tokenize(_T("\r\n"), iPos);
				}
				break;
			}
			case OP_IDCHANGE:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_IDChange\n"));
				if (size < sizeof(LoginAnswer_Struct)){
					throw GetResString(IDS_ERR_BADSERVERREPLY);
				}
				LoginAnswer_Struct* la = (LoginAnswer_Struct*)packet;

				// save TCP flags in 'cur_server'
				CServer* pServer = NULL;
				ASSERT( cur_server );
				if (cur_server){
					if (size >= sizeof(LoginAnswer_Struct)+4){
						DWORD dwFlags = *((uint32*)(packet + sizeof(LoginAnswer_Struct)));
						if (thePrefs.GetDebugServerTCPLevel() > 0){
							CString strInfo;
							strInfo.AppendFormat(_T("  TCP Flags=0x%08x"), dwFlags);
							const DWORD dwKnownBits = SRV_TCPFLG_COMPRESSION | SRV_TCPFLG_NEWTAGS | SRV_TCPFLG_UNICODE | SRV_TCPFLG_RELATEDSEARCH | SRV_TCPFLG_TYPETAGINTEGER | SRV_TCPFLG_LARGEFILES | SRV_TCPFLG_TCPOBFUSCATION;
							if (dwFlags & ~dwKnownBits)
								strInfo.AppendFormat(_T("  ***UnkBits=0x%08x"), dwFlags & ~dwKnownBits);
							if (dwFlags & SRV_TCPFLG_COMPRESSION)
								strInfo.AppendFormat(_T("  Compression=1"));
							if (dwFlags & SRV_TCPFLG_NEWTAGS)
								strInfo.AppendFormat(_T("  NewTags=1"));
							if (dwFlags & SRV_TCPFLG_UNICODE)
								strInfo.AppendFormat(_T("  Unicode=1"));
							if (dwFlags & SRV_TCPFLG_RELATEDSEARCH)
								strInfo.AppendFormat(_T("  RelatedSearch=1"));
							if (dwFlags & SRV_TCPFLG_TYPETAGINTEGER)
								strInfo.AppendFormat(_T("  IntTypeTags=1"));
							if (dwFlags & SRV_TCPFLG_LARGEFILES)
								strInfo.AppendFormat(_T("  LargeFiles=1"));
							if (dwFlags & SRV_TCPFLG_TCPOBFUSCATION)
								strInfo.AppendFormat(_T("  TCP_Obfscation=1"));
							Debug(_T("%s\n"), strInfo);
						}
						cur_server->SetTCPFlags(dwFlags);
					}
					else
						cur_server->SetTCPFlags(0);

					// copy TCP flags into the server in the server list
					pServer = theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort());
					if (pServer)
						pServer->SetTCPFlags(cur_server->GetTCPFlags());
				}

				uint32 dwServerReportedIP = 0;
				uint32 dwObfuscationTCPPort = 0;
				if (size >= 20){
					dwServerReportedIP = *((uint32*)(packet + 12));
					if (::IsLowID(dwServerReportedIP)){
						ASSERT( false );
						dwServerReportedIP = 0;
					}
					ASSERT( dwServerReportedIP == la->clientid || ::IsLowID(la->clientid) );
					dwObfuscationTCPPort = *((uint32*)(packet + 16));
					if (cur_server != NULL && dwObfuscationTCPPort != 0)
						cur_server->SetObfuscationPortTCP((uint16)dwObfuscationTCPPort);
					if (pServer != NULL && dwObfuscationTCPPort != 0)
						pServer->SetObfuscationPortTCP((uint16)dwObfuscationTCPPort);

				}

				//Xman
				// Maella -Activate Smart Low ID check-
				/*
				if (la->clientid == 0)
				{
					uint8 state = thePrefs.GetSmartIdState();
					if ( state > 0 )
					{
						if (state == 1)
							theApp.emuledlg->RefreshUPnP(false); // refresh the UPnP mappings once
						state++;
						if( state > 2 )
							thePrefs.SetSmartIdState(0);
						else
							thePrefs.SetSmartIdState(state);
					}
					break;
				}
				if( thePrefs.GetSmartIdCheck() ){
					if (!IsLowID(la->clientid))
						thePrefs.SetSmartIdState(1);
					else{
						uint8 state = thePrefs.GetSmartIdState();
						if ( state > 0 )
						{
							if (state == 1)
								theApp.emuledlg->RefreshUPnP(false); // refresh the UPnP mappings once
							state++;
							if( state > 2 )
								thePrefs.SetSmartIdState(0);
							else
								thePrefs.SetSmartIdState(state);

							if (!m_bManualSingleConnect)
								break; // if this is a connect to any/multiple server connection try, disconnect and try another one
						}
					}
				}
				*/
				if(la->clientid == 0){
					// Reset attempts counter
					thePrefs.SetSmartIdState(0);
				}
				else if(la->clientid >= 16777216){
					// High ID => reset attempts counter
					thePrefs.SetSmartIdState(0);
				}
				else if(thePrefs.GetSmartIdCheck() == true){
					// Low ID => Check and increment attempts counter
					uint8 attempts = thePrefs.GetSmartIdState();
					if(attempts < 3){
						//zz_fly :: not needed, rebind upnp on ipchange :: start
						//Official UPNP
						/*
						if (!thePrefs.m_bUseACATUPnPCurrent && (attempts == 1))
							theApp.emuledlg->RefreshUPnP(false); // refresh the UPnP mappings once
						*/
						//zz_fly :: end
						SetConnectionState(CS_ERROR);
						thePrefs.SetSmartIdState(++attempts);
						AddLogLine(true, _T("LowID -- Trying Again (attempts %i)"), attempts);
						break; // Retries
					}
					else if (!m_bManualSingleConnect)
						break; // if this is a connect to any/multiple server connection try, disconnect and try another one
				}
				//Xman end
				
				// we need to know our client's HighID when sending our shared files (done indirectly on SetConnectionState)
				serverconnect->clientid = la->clientid;

				if (connectionstate != CS_CONNECTED) {
					SetConnectionState(CS_CONNECTED);
					theApp.OnlineSig();       // Added By Bouc7 
				}
				serverconnect->SetClientID(la->clientid);
				if (::IsLowID(la->clientid) && dwServerReportedIP != 0)
					theApp.SetPublicIP(dwServerReportedIP);
				AddLogLine(false, GetResString(IDS_NEWCLIENTID), la->clientid);

				//Xman -Reask sources after IP change- v4
				if(serverconnect->GetClientID() != 0 && theApp.last_valid_ip != 0
				   && serverconnect->GetClientID() != theApp.last_valid_ip 
				   && serverconnect->GetClientID() != theApp.last_valid_serverid)
				{
					//remark: this code doesn't trigger when changing low->hidh-ID and we already had
					//a session with this HighID-IP. This is because we don't know when this last lowID-session was.
					//but there is no need to trigger when changing low to high-id but keeping the IP, we can'tt loose the waiting-position!

					{
						// Public IP has been changed, it's necessary to inform all sources about it
						// All sources would be informed during their next session refresh (with TCP)
						// about the new IP.
						// ==> Quick start [TPT] - Max
						if(thePrefs.GetQuickStart() && thePrefs.GetQuickStartAfterIPChange())
						{
							theApp.downloadqueue->quickflag = 0;
							theApp.downloadqueue->quickflags = 0;
						}
						// <== Quick start [TPT] - Max
						if(GetTickCount() - theApp.last_ip_change > FILEREASKTIME + 60000){
							theApp.clientlist->TrigReaskForDownload(true);
							theApp.last_ip_change=::GetTickCount();
							theApp.m_bneedpublicIP=false;
							AddLogLine(false, _T("Change from %u (%s ID) to %u (%s ID) detected%s"), 
								theApp.last_valid_serverid,
								(theApp.last_valid_serverid < 16777216) ? _T("low") : _T("high"),
								serverconnect->GetClientID(),
								(serverconnect->GetClientID() < 16777216)  ? _T("low") : _T("high"),
								_T(", all sources will be reasked immediately"));
						}
						else {
							theApp.clientlist->TrigReaskForDownload(false);
							theApp.last_ip_change=::GetTickCount();
							theApp.m_bneedpublicIP=false;
							AddLogLine(false, _T("Change from %u (%s ID) to %u (%s ID) detected%s"), 
								theApp.last_valid_serverid,
								(theApp.last_valid_serverid < 16777216) ? _T("low") : _T("high"),
								serverconnect->GetClientID(),
								(serverconnect->GetClientID() < 16777216)  ? _T("low") : _T("high"),
								_T(", all sources will be reasked within the next 10 minutes"));
						}
						// ==> UPnP support [MoNKi] - leuk_he
						/*
						// official UPNP
						theApp.emuledlg->RefreshUPnP(false); // refresh the UPnP mappings once
						// official UPNP
						*/
						theApp.RebindUPnP();
						// <== UPnP support [MoNKi] - leuk_he
					}
				}
				if(serverconnect->GetClientID() != 0 && theApp.last_ip_change==0)
					theApp.last_ip_change=::GetTickCount();
				if(serverconnect->GetClientID() != 0 && serverconnect->GetClientID() != theApp.last_valid_serverid){
					// Keep track of a change of the global IP
					theApp.last_valid_serverid = serverconnect->GetClientID();
				}
				theApp.last_valid_ip=theApp.GetPublicIP(true); //can also be 0

				theApp.last_traffic_reception=::GetTickCount();
				theApp.internetmaybedown=false; //we have to reopen here if we are using server only
				// Xman end

				theApp.downloadqueue->ResetLocalServerRequests();
				break;
			}
			case OP_SEARCHRESULT:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_SearchResult\n"));
				CServer* cur_srv = (serverconnect) ? serverconnect->GetCurrentServer() : NULL;
				CServer* pServer = cur_srv ? theApp.serverlist->GetServerByAddress(cur_srv->GetAddress(), cur_srv->GetPort()) : NULL;
				(void)pServer;
				bool bMoreResultsAvailable;
				UINT uSearchResults = theApp.searchlist->ProcessSearchAnswer(packet, size, true/*pServer ? pServer->GetUnicodeSupport() : false*/, cur_srv ? cur_srv->GetIP() : 0, cur_srv ? cur_srv->GetPort() : (uint16)0, &bMoreResultsAvailable);
				theApp.emuledlg->searchwnd->LocalEd2kSearchEnd(uSearchResults, bMoreResultsAvailable);
				break;
			}
			case OP_FOUNDSOURCES_OBFU:
			case OP_FOUNDSOURCES:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_FoundSources%s; Sources=%u  %s\n"), (opcode == OP_FOUNDSOURCES_OBFU) ? _T("_OBFU") : _T(""), (UINT)packet[16], DbgGetFileInfo(packet));

				ASSERT( cur_server );
				if (cur_server)
				{
				    CSafeMemFile sources(packet, size);
					uchar fileid[16];
					sources.ReadHash16(fileid);
					if (CPartFile* file = theApp.downloadqueue->GetFileByID(fileid))
						file->AddSources(&sources,cur_server->GetIP(), cur_server->GetPort(), (opcode == OP_FOUNDSOURCES_OBFU));
				}
				break;
			}
			case OP_SERVERSTATUS:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_ServerStatus\n"));
				// FIXME some statuspackets have a different size -> why? structur?
				if (size < 8)
					break;//throw "Invalid status packet";
				uint32 cur_user = PeekUInt32(packet);
				uint32 cur_files = PeekUInt32(packet+4);
				CServer* pServer = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()) : NULL;
				if (pServer){
					pServer->SetUserCount(cur_user);
					pServer->SetFileCount(cur_files);
					theApp.emuledlg->ShowUserCount();
					theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer(pServer);
					theApp.emuledlg->serverwnd->UpdateMyInfo();
				}
				if (thePrefs.GetDebugServerTCPLevel() > 0){
					if (size > 8){
						Debug(_T("*** NOTE: OP_ServerStatus: ***AddData: %u bytes\n"), size - 8);
						DebugHexDump(packet + 8, size - 8);
					}
				}
				break;
			}
			case OP_SERVERIDENT:{
				// OP_SERVERIDENT - this is sent by the server only if we send a OP_GETSERVERLIST
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_ServerIdent\n"));
				if (size<16+4+2+4){
					if (thePrefs.GetVerbose())
						DebugLogError(_T("%s"), GetResString(IDS_ERR_KNOWNSERVERINFOREC));
					break;// throw "Invalid server info received"; 
				} 

				CServer* pServer = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(),cur_server->GetPort()) : NULL;
				CString strInfo;
				CSafeMemFile data(packet, size);
				
				uint8 aucHash[16];
				data.ReadHash16(aucHash);
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					strInfo.AppendFormat(_T("Hash=%s (%s)"), md4str(aucHash), DbgGetHashTypeString(aucHash));
				uint32 nServerIP = data.ReadUInt32();
				uint16 nServerPort = data.ReadUInt16();
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					strInfo.AppendFormat(_T("  IP=%s:%u"), ipstr(nServerIP), nServerPort);
				UINT nTags = data.ReadUInt32();
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					strInfo.AppendFormat(_T("  Tags=%u"), nTags);

				CString strName;
				CString strDescription;
				for (UINT i = 0; i < nTags; i++){
					CTag tag(&data, pServer ? pServer->GetUnicodeSupport() : false);
					if (tag.GetNameID() == ST_SERVERNAME){
						if (tag.IsStr()){
							strName = tag.GetStr();
							if (thePrefs.GetDebugServerTCPLevel() > 0)
								strInfo.AppendFormat(_T("  Name=%s"), strName);
						}
					}
					else if (tag.GetNameID() == ST_DESCRIPTION){
						if (tag.IsStr()){
							strDescription = tag.GetStr();
							if (thePrefs.GetDebugServerTCPLevel() > 0)
								strInfo.AppendFormat(_T("  Desc=%s"), strDescription);
						}
					}
					else if (thePrefs.GetDebugServerTCPLevel() > 0)
						strInfo.AppendFormat(_T("  ***UnkTag: 0x%02x=%u"), tag.GetNameID(), tag.GetInt());
				}
				if (thePrefs.GetDebugServerTCPLevel() > 0){
					strInfo += _T('\n');
					Debug(_T("%s"), strInfo);

					UINT uAddData = (UINT)(data.GetLength() - data.GetPosition());
					if (uAddData > 0){
						Debug(_T("*** NOTE: OP_ServerIdent: ***AddData: %u bytes\n"), uAddData);
						DebugHexDump(packet + data.GetPosition(), uAddData);
					}
				}

				if (pServer){
					pServer->SetListName(strName);
					pServer->SetDescription(strDescription);
					if (((uint32*)aucHash)[0] == 0x2A2A2A2A){
						const CString& rstrVersion = pServer->GetVersion();
						if (!rstrVersion.IsEmpty())
							pServer->SetVersion(_T("eFarm ") + rstrVersion);
						else
							pServer->SetVersion(_T("eFarm"));
					}
					theApp.emuledlg->ShowConnectionState(); 
					theApp.emuledlg->serverwnd->serverlistctrl.RefreshServer(pServer); 
				}
				break;
			} 
			// tecxx 1609 2002 - add server's serverlist to own serverlist
			case OP_SERVERLIST:{
				if (!thePrefs.GetAddServersFromServer())
					break;
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_ServerList\n"));
				try{
					CSafeMemFile servers(packet, size);
					UINT count = servers.ReadUInt8();
					// check if packet is valid
					if (1 + count*(4+2) > size)
						count = 0;
					int addcount = 0;
					while(count)
					{
						uint32 ip = servers.ReadUInt32();
						uint16 port = servers.ReadUInt16();
						CServer* srv = new CServer(port, ipstr(ip));
						srv->SetListName(srv->GetFullIP());
						srv->SetPreference(SRV_PR_LOW);
						if (!theApp.emuledlg->serverwnd->serverlistctrl.AddServer(srv, true))
							delete srv;
						else
							addcount++;
						count--;
					}
					if (addcount)
						AddLogLine(false, GetResString(IDS_NEWSERVERS), addcount);
					if (thePrefs.GetDebugServerTCPLevel() > 0){
						UINT uAddData = (UINT)(servers.GetLength() - servers.GetPosition());
						if (uAddData > 0){
							Debug(_T("*** NOTE: OP_ServerList: ***AddData: %u bytes\n"), uAddData);
							DebugHexDump(packet + servers.GetPosition(), uAddData);
						}
					}
				}
				catch(CFileException* error){
					if (thePrefs.GetVerbose())
						DebugLogError(_T("%s"), GetResString(IDS_ERR_BADSERVERLISTRECEIVED));
					error->Delete();
				}
				break;
			}
			case OP_CALLBACKREQUESTED:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_CallbackRequested: %s\n"), (size >= 23) ? _T("With Cryptflag and Userhash") : _T("Without Cryptflag and Userhash"));
				if (size >= 6)
				{
					uint32 dwIP = PeekUInt32(packet);

					if (theApp.ipfilter->IsFiltered(dwIP)){
						theStats.filteredclients++;
						if (thePrefs.GetLogFilteredIPs())
							AddDebugLogLine(false, _T("Ignored callback request (IP=%s) - IP filter (%s)"), ipstr(dwIP), theApp.ipfilter->GetLastHit());
						break;
					}

					if (theApp.clientlist->IsBannedClient(dwIP)){
						if (thePrefs.GetLogBannedClients()){
							CUpDownClient* pClient = theApp.clientlist->FindClientByIP(dwIP);
							//Xman Code Fix
							/*
							AddDebugLogLine(false, _T("Ignored callback request from banned client %s; %s"), ipstr(dwIP), pClient->DbgGetClientInfo());
							*/
							AddDebugLogLine(false, _T("Ignored callback request from banned client %s; %s"), ipstr(dwIP), pClient ? pClient->DbgGetClientInfo() : _T("unknown"));
							//Xman end
						}
						break;
					}

					uint16 nPort = PeekUInt16(packet+4);
					uint8 byCryptOptions = 0;
					uchar achUserHash[16];
					if (size >= 23){
						byCryptOptions = packet[6];
						md4cpy(achUserHash, packet + 7);
					}
					
					CUpDownClient* client = theApp.clientlist->FindClientByIP(dwIP,nPort);
					if (client == NULL)
					{
						client = new CUpDownClient(0,nPort,dwIP,0,0,true);
						//Xman Code Improvement don't search new generated clients in lists
						/*
						theApp.clientlist->AddClient(client);
						*/
						theApp.clientlist->AddClient(client, true);
						//Xman end
					}
					if (size >= 23 && client->HasValidHash()){
						if (md4cmp(client->GetUserHash(), achUserHash) != 0){
							DebugLogError(_T("Reported Userhash from OP_CALLBACKREQUESTED differs with our stored hash"));
							// disable crypt support since we dont know which hash is true
							client->SetCryptLayerRequest(false);
							client->SetCryptLayerSupport(false);
							client->SetCryptLayerRequires(false);
						}
						else{
							client->SetConnectOptions(byCryptOptions, true, false);
							client->SetDirectUDPCallbackSupport(false);
						}
					}
					else if (size >= 23){
						client->SetUserHash(achUserHash);
						client->SetCryptLayerSupport((byCryptOptions & 0x01) != 0);
						client->SetCryptLayerRequest((byCryptOptions & 0x02) != 0);
						client->SetCryptLayerRequires((byCryptOptions & 0x04) != 0);
						client->SetDirectUDPCallbackSupport(false);
					}
					client->TryToConnect();
				}
				break;
			}
			case OP_CALLBACK_FAIL:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_Callback_Fail %s\n"), DbgGetHexDump(packet, size));
				break;
			}
			case OP_REJECT:{
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("ServerMsg - OP_Reject %s\n"), DbgGetHexDump(packet, size));
				// this could happen if we send a command with the wrong protocol (e.g. sending a compressed packet to
				// a server which does not support that protocol).
				if (thePrefs.GetVerbose())
					DebugLogError(_T("Server rejected last command"));
				break;
			}
			default:
				if (thePrefs.GetDebugServerTCPLevel() > 0)
					Debug(_T("***NOTE: ServerMsg - Unknown message; opcode=0x%02x  %s\n"), opcode, DbgGetHexDump(packet, size));
				;
		}

		return true;
	}
	catch(CFileException* error)
	{
		if (thePrefs.GetVerbose())
		{
			TCHAR szError[MAX_CFEXP_ERRORMSG];
			error->m_strFileName = _T("server packet");
			error->GetErrorMessage(szError, ARRSIZE(szError));
			ProcessPacketError(size, opcode, szError);
		}
		ASSERT(0);
		error->Delete();
		if (opcode==OP_SEARCHRESULT || opcode==OP_FOUNDSOURCES)
			return true;
	}
	catch(CMemoryException* error)
	{
		ProcessPacketError(size, opcode, _T("CMemoryException"));
		ASSERT(0);
		error->Delete();
		if (opcode==OP_SEARCHRESULT || opcode==OP_FOUNDSOURCES)
			return true;
	}
	catch(CString error)
	{
		ProcessPacketError(size, opcode, error);
		ASSERT(0);
	}
#ifndef _DEBUG
	catch(...)
	{
		ProcessPacketError(size, opcode, _T("Unknown exception"));
		ASSERT(0);
	}
#endif

	SetConnectionState(CS_DISCONNECTED);
	return false;
}
Exemplo n.º 25
0
void CServerSocket::OnError(int nErrorCode)
{
	SetConnectionState(CS_DISCONNECTED);
	if (thePrefs.GetVerbose())
		DebugLogError(GetResString(IDS_ERR_SOCKET), cur_server->GetListName(), cur_server->GetAddress(), cur_server->GetPort(), GetFullErrorMessage(nErrorCode));
}
Exemplo n.º 26
0
tResult cJuryModule::ConnectDisconnectNetworkClients()
{
    if (m_pNetwork)
    {
        // network is present, so we have to disconnect
        QString strText = QString("Disconnecting...");
        SetLogText(strText);
        m_bConnected = false;
        SetConnectionState();
        
        m_pNetwork->DestroySystem(m_pLocalSystemSender);
        m_pNetwork->DestroySystem(m_pRemoteSystem);
        CleanUpNetwork();
        
        strText = QString("Disconnected");
        SetLogText(strText);

        RETURN_NOERROR;
    }

    // network is not present, connect
    QString strText = QString("Trying to connect to ") + QString(GetIpAdress().c_str()) + QString(" ...");
    SetLogText(strText);
    
    // create new network
    m_pNetwork = new cNetwork("");
    cNetwork::SetLogLevel(cNetwork::eLOG_LVL_ERROR);

    //Initialize the network
    tResult nRes = m_pNetwork->Init();
    if (ERR_NOERROR != nRes) //Never forget the error check
    {
        CleanUpNetwork();
        return nRes;
    }

    const tInt nFlags = 0;

    tString strIp = GetIpAdress();
    
    //Create one local system which is part of the network
    //this is to send data to the world !! 
    const tString strDataSendUrl("tcp://" + strIp + ":5000");
    m_pLocalSystemSender = NULL;                 //Gets assigned while created
    const tString strLocalSystemNameData("JuryModuleData"); //Name of the first system
    nRes = m_pNetwork->CreateLocalSystem(&m_pLocalSystemSender,
        strLocalSystemNameData,
        strDataSendUrl,
        nFlags);//if not given, default = 0
    if (ERR_NOERROR != nRes)
    {
        CleanUpNetwork();
        return nRes;
    }

    //the system can also have some data available
    nRes = m_pLocalSystemSender->GetDataServer(&m_pDataSystemDataSender);
    if (ERR_NOERROR != nRes)
    {
        CleanUpNetwork();
        return nRes;
    }

    // check if there is a description file set, otherwise use the coded description
    QString strDescriptionFile = m_pWidget->m_edtDescriptionFile->text();
    tString strMyDDLDefinitionAsString;
    if (!QFile::exists(strDescriptionFile))
    {
        SetLogText("No valid media description file set. Will use the internal description.");
        strMyDDLDefinitionAsString = CONNLIB_JURY_MODULE_DDL_AS_STRING;
    }
    else
    {
        SetLogText(QString("Using media description file ") + strDescriptionFile);
        strMyDDLDefinitionAsString = strDescriptionFile.toStdString();
    }
        
    nRes = m_pDataSystemDataSender->AddDDL(strMyDDLDefinitionAsString);
    if (ERR_NOERROR != nRes)
    {
        SetLogText("Media description not valid. Please set a valid file.");
        CleanUpNetwork();
        return nRes;
    }

    // define the description of outgoing data
    tDataDesc sDescEmergencyStopRaw;
    sDescEmergencyStopRaw.strName = CONLIB_OUT_PORT_NAME_EMERGENCY_STOP;
    sDescEmergencyStopRaw.strDescriptionComment = "The emergency stop struct in raw mode";
    sDescEmergencyStopRaw.strType = "plainraw";
    nRes = m_pDataSystemDataSender->PublishPlainData(CONLIB_STREAM_NAME_EMERGENCY_STOP, sDescEmergencyStopRaw);
    if (ERR_NOERROR != nRes)
    {
        CleanUpNetwork();
        return nRes;
    }

    tDataDesc sDescJuryStruct;
    sDescJuryStruct.strName = CONLIB_OUT_PORT_NAME_JURY_STRUCT;
    sDescJuryStruct.strDescriptionComment = "the jury data as struct";
    sDescJuryStruct.strType = "plainraw";
    nRes = m_pDataSystemDataSender->PublishPlainData(CONLIB_STREAM_NAME_JURY_STRUCT, sDescJuryStruct);
    if (ERR_NOERROR != nRes)
    {
        CleanUpNetwork();
        return nRes;
    }


    tDataDesc sDescManeuverList;
    sDescManeuverList.strName = CONLIB_OUT_PORT_NAME_MANEUVER_LIST;
    sDescManeuverList.strDescriptionComment = "the Manuverlist as string";
    sDescManeuverList.strType = "plainraw";
    nRes = m_pDataSystemDataSender->PublishPlainData(CONLIB_STREAM_NAME_MANEUVER_LIST, sDescManeuverList);
    if (ERR_NOERROR != nRes)
    {
        CleanUpNetwork();
        return nRes;
    }

    //this is to receive data from a specific sender!!

    //Create one local system which is part of the network
    const tString strDataUrl("tcp://" + strIp + ":5000");
    m_pRemoteSystem = NULL;               //Gets assigned while created
    const tString strSystemNameData("ADTFData"); //Name of the first system
    nRes = m_pNetwork->CreateRemoteSystem(&m_pRemoteSystem,
        strSystemNameData,
        strDataUrl,
        nFlags);//if not given, default = 0
    if (ERR_NOERROR != nRes)
    {
        CleanUpNetwork();
        return nRes;
    }

    nRes = m_pRemoteSystem->GetDataServer(&m_pDataRemoteSystemData);
    if (ERR_NOERROR != nRes)
    {
        CleanUpNetwork();
        return nRes;
    }

    //this is only required if you subscribe to raw data, otherwise the DDL will be transmitted by the sender.
    m_pDataRemoteSystemData->AddDDL(strMyDDLDefinitionAsString);

    m_pDataRemoteSystemData->SubscribeForPlainDataRaw(CONLIB_IN_PORT_NAME_DRIVER_STRUCT, CONLIB_STREAM_NAME_DRIVER_STRUCT, this);

    m_pDataRemoteSystemData->SubscribeForPlainDataRaw(CONLIB_IN_PORT_NAME_JURY_STRUCT_LOOPBACK, CONLIB_STREAM_NAME_JURY_STRUCT, this);

    m_pDataRemoteSystemData->SubscribeForPlainDataRaw(CONLIB_IN_PORT_NAME_EMERGENCY_STOP_LOOPBACK, CONLIB_STREAM_NAME_EMERGENCY_STOP, this);

    m_pDataRemoteSystemData->SubscribeForPlainDataRaw(CONLIB_IN_PORT_NAME_MANEUVER_LIST, CONLIB_STREAM_NAME_MANEUVER_LIST, this);

    // set the connection state in ui
    strText = QString("Connected to ") + QString(GetIpAdress().c_str());
    SetLogText(strText);
    
    m_bConnected = true;
    SetConnectionState();

    RETURN_NOERROR;
}
Exemplo n.º 27
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    int i;
    QLineEdit *curr_msg = NULL;

    liveEditingEnabled=false;
    is_normal = true;
    moving = false;
    acceptClose = false;
    deviceStatus = false;
    toolBarIsVisible = false;
    listener=NULL;
    fmtxCmdSpecial = FMTX_SPECIAL_FRONTEND; ///< At the startup point we want to work with frontend
    fmtxEEPROMInfoClean();

    erroricon = QIcon(":/fmstick/images/Gnome-Network-Wireless-NoTxError-64.png");
    warningicon = QIcon(":/fmstick/images/Gnome-Network-Wireless-NoTxWarning-64.png");
    notxicon = QIcon(":/fmstick/images/Gnome-Network-Wireless-NoTx-64.png");
    txicon = QIcon(":/fmstick/images/fmstick.png");
    nodeviceicon = QIcon(":/fmstick/images/Gnome-Network-Wireless-NoDevice-64.png");

    CurrentVersion = REVISION;
    CurrentVersion.replace(QRegExp("^\\$Rev: (\\d+) \\$$"), "\\1");
    CurrentVersion =  QString(VERSION) + "." + CurrentVersion;

    ui->setupUi(this);

    ui->lineEdit_sw_ver->setText(CurrentVersion);
    ui->checkBox_sw_runAtStartup->setChecked(GetRunAtStartup());
    audioLimiter_prev_div = 0;
    SetAudioCompLimByPreset(4);

    /* actions */
    connect( ui->actionOpen, SIGNAL(triggered()),
             this, SLOT(ReadFrontendParams()) );
    connect( ui->actionSave, SIGNAL(triggered()),
             this, SLOT(SaveFrontendParams()) );

    connect( ui->actionReset_to_Default, SIGNAL(triggered()),
             this, SLOT(resetFmTxSettings()) );
    connect( ui->actionRead_from_Device, SIGNAL(triggered()),
             this, SLOT(GetFrontendParams()) );
    connect( ui->actionWrite_to_Device, SIGNAL(triggered()),
             this, SLOT(SetFrontendParams()) );
    connect( ui->actionRead_from_EEPROM, SIGNAL(triggered()),
             this, SLOT(ShowEEPROMParams()) );
    connect( ui->actionWrite_to_EEPROM, SIGNAL(triggered()),
             this, SLOT(SaveEEPROMParams()) );

    connect( ui->actionSkin_changeMode, SIGNAL(triggered()),
             this, SLOT(toggleWindowMode()) );
    connect( ui->actionToggle_ToolBar, SIGNAL(triggered()),
             this, SLOT(toggleToolBar()));
    connect( ui->actionChange_RadioText, SIGNAL(triggered()),
             this, SLOT(DisplayRadioTextDialog()) );

    connect( ui->actionExit, SIGNAL(triggered()),
             this, SLOT(quit()) );
    connect( ui->actionToggle_transmission, SIGNAL(triggered()),
             this, SLOT(StationButtonClicked()) );
    connect( ui->actionConnect_to_device, SIGNAL(triggered()),
             this, SLOT(SetConnectionState()));
    connect(ui->actionAbout, SIGNAL(triggered()),
            this, SLOT(ShowAboutApp()));

    /* audio compressor/limiter */
    connect( ui->comboBox_audioPreset, SIGNAL(currentIndexChanged(int)),
             this, SLOT(SetAudioCompLimByPreset(int)) );
    connect( ui->checkBox_audio_enablecompressor, SIGNAL( stateChanged(int) ),
             this, SLOT( toggleCompressor(int) ) );
    connect( ui->spinBox_audiocompressorThreshold, SIGNAL( valueChanged(int) ),
            this, SLOT( SetAudioCompressorThreshold(int) ) );
    connect( ui->spinBox_audioCompressorGain, SIGNAL(valueChanged(int)),
             this, SLOT(SetAudioCompressorGain(int)));
    connect( ui->comboBox_audioCompressorReleasetime, SIGNAL(currentIndexChanged(int)),
             this, SLOT(SetAudioCompressorReleaseTime(int)));
    connect( ui->doubleSpinBox_audioCompressorAttackTime, SIGNAL(valueChanged(double)),
             this, SLOT(SetAudioCompressorAttackTime(double)));
    connect( ui->checkBox_audioLimiterEnable , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleLimiter(int) ) );
    connect( ui->doubleSpinBox_audio_lim_release_time, SIGNAL(valueChanged(double)),
             this, SLOT(SetAudioLimiterReleaseTime(double)));
    connect( ui->comboBox_audio_input_level, SIGNAL(currentIndexChanged(int)),
             this, SLOT(SetAudioStandAlone(int)));
    connect( ui->spinBox_audio_input_amplitude, SIGNAL(valueChanged(int)),
             this, SLOT(SetAudioStandAlone()));
    connect( ui->comboBox_audio_input_mute, SIGNAL(currentIndexChanged(int)),
             this, SLOT(SetAudioStandAloneMute(int)));


    /* audio signal quality measurement */
    connect( ui->checkBox_asq_overmoddetect, SIGNAL( stateChanged(int) ),
             this, SLOT(SetAudioASQFlags()));
    connect( ui->checkBox_asq_detectLow , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleASQLow(int) ) );
    connect( ui->spinBox_asq_detectLowThreshold, SIGNAL(valueChanged(int)),
             this, SLOT(SetAudioASQLevelLow(int)));
    connect( ui->spinBox_asq_detectLowDuration, SIGNAL(valueChanged(int)),
             this, SLOT(SetAudioASQDurationLow(int)));
    connect( ui->checkBox_asq_detectHigh , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleASQHigh(int) ) );
    connect( ui->spinBox_asq_detectHighThreshold, SIGNAL(valueChanged(int)),
             this, SLOT(SetAudioASQLevelHigh(int)));
    connect( ui->spinBox_asq_detectHighDuration, SIGNAL(valueChanged(int)),
             this, SLOT(SetAudioASQDurationHigh(int)));

    /* transmitter configuration */
    //checkBox_transmitter_pilot: spinBox_transmitter_pilot_devi, spinBox_transmitter_pilot_freq, checkBox_transmitter_lmr
    //checkBox_transmitter_rds: spinBox_transmitter_rds_devi
    //checkBox_transmitter_enabled: doubleSpinBox_transmitter_freq spinBox_transmitter_power ==> txcap
    // \==> checkBox_transmitter_antcap: doubleSpinBox_transmitter_antcap_val
    connect( ui->checkBox_transmitter_pilot , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleTransmitPilot(int) ) );
    connect( ui->checkBox_transmitter_rds , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleTransmitRds(int) ) );
    connect( ui->checkBox_transmitter_lmr , SIGNAL( stateChanged(int) ),
             this, SLOT( SetTransmitComponentFlags() ) );

    connect( ui->checkBox_transmitter_enabled , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleTransmitEnabled(int) ) );
    connect( ui->checkBox_transmitter_antcap , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleTransmitAntCap(int) ) );
    connect( ui->comboBox_transmitter_preemph, SIGNAL(currentIndexChanged(int)),
             this, SLOT(SetTransmitPreemphasis(int)));
    connect( ui->spinBox_transmitter_audioDev, SIGNAL(valueChanged(int)),
             this, SLOT(SetTransmitAudioDeviation(int)));

    connect( ui->spinBox_transmitter_pilot_devi, SIGNAL(valueChanged(int)),
             this, SLOT( SetTransmitPilotDeviation(int) ) );
    connect( ui->spinBox_transmitter_pilot_freq, SIGNAL(valueChanged(int)),
             this, SLOT( SetTransmitPilotFrequency(int) ) );
    connect( ui->spinBox_transmitter_rds_devi, SIGNAL(valueChanged(int)),
             this, SLOT( SetTransmitRDSDeviation(int) ) );
    connect( ui->doubleSpinBox_transmitter_freq, SIGNAL(valueChanged(double)),
             this, SLOT( SetTransmitFrequency(double) ) );
    connect( ui->spinBox_transmitter_power, SIGNAL(valueChanged(int)),
             this, SLOT( SetTransmitPower() ) );
    connect( ui->doubleSpinBox_transmitter_antcap_val, SIGNAL(valueChanged(double)),
             this, SLOT( SetTransmitPower() ) );

    /* RDS Configuration */
    //checkBox_rds_useaf: doubleSpinBox_rds_af
    //checkBox_rds_fifo: spinBox_rds_fifo_sz
    // \==> checkBox_rds_time: spinBox_rds_time_int
    connect( ui->lineEdit_rds_progid, SIGNAL( editingFinished()),
             this, SLOT( SetRDSPI() ));
    connect( ui->checkBox_rds_useaf , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleRDSaf(int) ) );
    connect( ui->doubleSpinBox_rds_af, SIGNAL(valueChanged(double)),
             this, SLOT( SetRDSAF(double) ));
    connect( ui->checkBox_rds_fifo , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleRDSfifo(int) ) );
    connect( ui->spinBox_rds_fifo_sz , SIGNAL(valueChanged(int)),
             this, SLOT( SetRDSFIFO(int) ) );
    connect( ui->spinBox_rds_ps_msgs , SIGNAL( valueChanged(int) ),
             this, SLOT( toggleRDSPSNum(int) ) );
    connect( ui->spinBox_rds_ps_repeats , SIGNAL( valueChanged(int) ),
             this, SLOT( SetRDSPSRepeats(int) ) );
    connect( ui->comboBox_rds_ps_percentage, SIGNAL(currentIndexChanged(int)),
             this, SLOT(SetRDSPSPercentage(int)));

    /* this boths PS msg editors must not re-block each other */
    connect( ui->lineEdit_station_id, SIGNAL(textChanged(QString)), this, SLOT( toggleRDSPSMsg(QString)) );
    for(i=0; i<12; i++){
        curr_msg = GetRDSLineEditById(i);
        //if(curr_msg) connect( curr_msg, SIGNAL(editingFinished()), this, SLOT(toggleStationId()) );
        //if(curr_msg) connect( curr_msg, SIGNAL(textEdited(QString)), this, SLOT(toggleStationId()) );
        if(curr_msg) connect( curr_msg, SIGNAL(textChanged(QString)), this, SLOT(toggleStationId()) );
    }

    /* RadioText */
    connect( ui->plainTextEdit_rds_rt, SIGNAL(textChanged()),
             this, SLOT(toggleRDSRT()));

    /* misc flags */
    connect( ui->checkBox_rds_art_head, SIGNAL(stateChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );
    connect( ui->checkBox_rds_compr_code, SIGNAL(stateChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );
    connect( ui->checkBox_rds_dynPT, SIGNAL(stateChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );
    connect( ui->checkBox_rds_forceb, SIGNAL(stateChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );
    connect( ui->checkBox_rds_is_stereo, SIGNAL(stateChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );
    connect( ui->checkBox_rds_ta, SIGNAL(stateChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );
    connect( ui->checkBox_rds_ta_tp, SIGNAL(stateChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );
    connect( ui->comboBox_rds_pty, SIGNAL(currentIndexChanged(int)),
             this, SLOT(SetRDSPsMiscFlags()) );


    /* StationId -> PS msg editor */
    //connect( ui->lineEdit_station_id, SIGNAL(textEdited(QString)),
    //         this, SLOT( toggleRDSPSMsg(QString)) );

    /* BigButton actions */
    connect( ui->commandLinkButton_station, SIGNAL(clicked()),
             this, SLOT(StationButtonClicked()) );
    connect( ui->commandLinkButton_station, SIGNAL(customContextMenuRequested(const QPoint &)),
             this, SLOT(StationButtonContextMenu(const QPoint &)) );

    /* hardware section */
    connect(ui->pushButton_fe_powerdown, SIGNAL(clicked()),
            this, SLOT(SetFrontendPowerDown()));
    connect(ui->pushButton_fe_powerup, SIGNAL(clicked()),
            this, SLOT(SetFrontendPowerUp()));
    connect(ui->pushButton_fe_reset, SIGNAL(clicked()),
            this, SLOT(SetFrontendReset()));
    connect( ui->pushButton_open_firmware, SIGNAL(clicked()),
             this, SLOT(UpdateFirmware()));
    connect( ui->checkBox_hw_run_txAtPowerUp , SIGNAL( toggled(bool) ),
             this, SLOT( SetRunEepromCfg(bool) ) );

    /* software configuration */
    connect( ui->checkBox_rds_time , SIGNAL( stateChanged(int) ),
             this, SLOT( toggleRDStime(int) ) );
    connect( ui->spinBox_rds_time_int , SIGNAL( valueChanged(int) ),
             this, SLOT( SetRDSTime(int) ) );
    connect( ui->checkBox_sw_runAtStartup, SIGNAL(stateChanged(int)),
             this, SLOT(SetRunAtStartup(int)) );
    connect( ui->checkBox_sw_live_edit, SIGNAL(toggled(bool)),
             this, SLOT(toggleLiveEditing(bool)));
    connect( ui->pushButton_sw_visitWebsite, SIGNAL(clicked()),
             this, SLOT(goToHomePage()));
    connect( ui->checkBox_sw_remote, SIGNAL(stateChanged(int)),
             this, SLOT(updateHTTPListener()));
    connect( ui->spinBox_sw_remote_port, SIGNAL(valueChanged(int)),
             this, SLOT(updateHTTPListener()));
    connect( ui->lineEdit_sw_remote_login, SIGNAL(editingFinished()),
             this, SLOT(updateHTTPListenerAccess()));
    connect( ui->lineEdit_sw_remote_pwd, SIGNAL(editingFinished()),
             this, SLOT(updateHTTPListenerAccess()));
//    connect( ui->textBrowser_sw_remote_uri, SIGNAL( highlighted( const QString&) ),
//             this, SLOT( openBrowser(const QString&)) );
    connect( ui->pushButton_sw_send_custom_rds, SIGNAL(clicked()),
             this, SLOT(SetRDSCustomGroup()));

#ifdef QT_NO_DEBUG
    loglevel=LOG_INFO;
#else
    loglevel=LOG_DUMP;
#endif

    querier = new Querier();
    /* actions from querier */
    connect( querier, SIGNAL(setASQOvermod(bool)), ui->label_audio_overmodulated, SLOT(setEnabled(bool)) );
    connect( querier, SIGNAL(setASQHighLevel(bool)),
             ui->label_audio_asq_triggered_high, SLOT(setEnabled(bool)) );
    connect( querier, SIGNAL(setASQLowLevel(bool)), ui->label_audio_asq_triggered_low, SLOT(setEnabled(bool)) );
    connect( querier, SIGNAL(setASQLevel(int)), this, SLOT(setAudioMeasuredLvl(int)) );
    connect( querier, SIGNAL(setTransmitterAntCap(double)),
             this, SLOT(setAntCapNoEvent(double)) );
    connect( querier, SIGNAL(setTransmitterTuned(int)), this, SLOT( SetTransmitIcon(int) ) );
    connect( querier, SIGNAL(setFrontendFound(bool)), this, SLOT(RedrawEverything(bool)) );

    connect( querier, SIGNAL(setRDSRTMessage(QString)), this, SLOT(updateRDSRTview(QString)) );
    connect( querier, SIGNAL(setRDSRTPlusMarks(QList<int> &, int)), this, SLOT(updateRDSRTPlusMark(QList<int> &, int)) );

    /* RadioText Plus (we need querier initializer 1st) */
    connect( ui->checkBox_rds_title_file, SIGNAL(stateChanged(int)),
             this, SLOT(UpdateRDSRTFileEnabled(int)));
    connect( ui->pushButton_open_rds_title, SIGNAL(clicked()),
             this, SLOT(UpdateRDSRTFile()));
    connect( ui->checkBox_rds_title_rtplus, SIGNAL(stateChanged(int)),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->lineEdit_rds_content1_reg, SIGNAL( editingFinished()),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->lineEdit_rds_content2_reg, SIGNAL( editingFinished()),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->comboBox_rds_content1_type, SIGNAL( currentIndexChanged(int)),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->comboBox_rds_content2_type, SIGNAL( currentIndexChanged(int)),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->lineEdit_rds_content3_reg, SIGNAL( editingFinished()),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->lineEdit_rds_content4_reg, SIGNAL( editingFinished()),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->comboBox_rds_content3_type, SIGNAL( currentIndexChanged(int)),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->comboBox_rds_content4_type, SIGNAL( currentIndexChanged(int)),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    connect( ui->checkBox_rds_dis_item, SIGNAL(stateChanged(int)),
             this, SLOT(UpdateRDSRTPlusEnabled()));
    //connect( ui->actionSelect_Language, SIGNAL(triggered(bool)), this, SLOT(showLanguageMenu(bool)) );
}