Exemple #1
0
// do a GET_COOKIE request followed by GET_WORD request or GET_RANDOM_WORD
// request (if word is NULL)
void StartCookieRequestWithWordLookup(AppContext* appContext, const char* word)
{
    ExtensibleBuffer request;
    ebufInit(&request, 0);
    Err error=CookieRequestPrepareRequest(request);
    if (error)
    {
        FrmAlert(alertMemError);
        goto Exit;
    }

    if (word)
    {
        ExtensibleBuffer* wordBuffer=ebufNew();
        if (wordBuffer)
        {
            ebufInitWithStr(wordBuffer, const_cast<char*>(word));
            ebufAddChar(wordBuffer, chrNull);
            StartConnection(appContext, wordBuffer, ebufGetDataPointer(&request), GeneralStatusTextRenderer, 
                CookieRequestResponseProcessorWithLookup,  CookieRequestContextDestructor);
        }
        else
            FrmAlert(alertMemError);
    }
    else
    {
        // this means GET_RANDOM_WORD in CookieRequestResponseProcessor
        StartConnection(appContext, NULL, ebufGetDataPointer(&request), GeneralStatusTextRenderer, 
            CookieRequestResponseProcessorWithLookup,  CookieRequestContextDestructor);
    }
Exit:
    ebufFreeData(&request);
}
Exemple #2
0
bool CServerBrowser::Event_QuickConnectSubmitClick ( CGUIElement_Impl * pElement )
{
	// Get the input text
	m_strServerIP = m_pQuickConnectAddress->GetText ();
	m_iServerPort = m_pQuickConnectPort->GetText().ToInteger ();
	m_strServerPassword = m_pQuickConnectPassword->GetText ();

	// Reset input text
	m_pQuickConnectAddress->SetText ( "" );
	m_pQuickConnectPort->SetText ( "" );
	m_pQuickConnectPassword->SetText ( "" );

	// If an invalid port is set, use the default?
	if ( m_iServerPort == 0 )
		m_iServerPort = 27015;

	// Start the connection
	StartConnection ();

	// Hide the quick connect window
	m_pQuickConnectWindow->SetVisible ( false );

	// Store the last server information
	CVAR_SET ( "last-server-ip", m_strServerIP.Get () );
	CVAR_SET ( "last-server-port", m_iServerPort );
	CVAR_SET ( "last-server-password", m_strServerPassword.Get () );

	return true;
}
Exemple #3
0
void StartRandomWordLookup(AppContext* appContext)
{
    if (!HasCookie(appContext->prefs))
        StartCookieRequestWithWordLookup(appContext, NULL);
    else
    {
        ExtensibleBuffer urlBuffer;
        ebufInit(&urlBuffer, 0);
        Err error=PrepareGenericRequest(appContext->prefs.cookie, randomWordRequestParam, urlBuffer);
        if (!error) 
        {
            const char* requestUrl=ebufGetDataPointer(&urlBuffer);
            ExtensibleBuffer* context=ebufNew();
            if (context)
            {
                ebufInitWithStr(context, "random word");
                ebufAddChar(context, chrNull);
                StartConnection(appContext, context, requestUrl, WordLookupStatusTextRenderer,
                    WordLookupResponseProcessor, WordLookupContextDestructor);
            }
            else 
                FrmAlert(alertMemError);            
        }
        else 
            FrmAlert(alertMemError);
        ebufFreeData(&urlBuffer);
    }
}
Exemple #4
0
void StartWordLookup(AppContext* appContext, const char* word)
{
    if (!HasCookie(appContext->prefs))
    {
        StartCookieRequestWithWordLookup(appContext, word);
        return;
    }

    ExtensibleBuffer urlBuffer;
    ebufInit(&urlBuffer, 0);
    Err error = WordLookupPrepareRequest(appContext->prefs.cookie, word, appContext->prefs.regCode, urlBuffer);
    if (error) 
    {
        FrmAlert(alertMemError);
        goto Exit;
    }

    const char* requestUrl = ebufGetDataPointer(&urlBuffer);
    ExtensibleBuffer* context = ebufNew();
    if (context)
    {
        ebufInitWithStr(context, const_cast<char*>(word));
        ebufAddChar(context, chrNull);
        StartConnection(appContext, context, requestUrl, WordLookupStatusTextRenderer,
            WordLookupResponseProcessor, WordLookupContextDestructor);
    }
    else 
        FrmAlert(alertMemError);            
Exit:
    ebufFreeData(&urlBuffer);
}
void CTe_LbsSuplConnStarter::ConstructL()
	{
	User::LeaveIfError(iSocketServ.Connect());
	User::LeaveIfError(iConnection.Open(iSocketServ));
	
	StartConnection();
	}
Exemple #6
0
bool KThruput::SetTimeScale(int value)
{
	TimeScale = value;

	/* Sonst kommen die Werte durcheinander */
	if (Connected >= 0)
	{
		StopConnection();
		StartConnection();
	}

	return TRUE;
}
// creates a connection and destroys it again
enum TVerdict TE_RConnectionTest300::doTestStepL(void)
{
	TInt err;

	RConnection activeConn;
	RConnection conn;
	RSocketServ ss;

	TRequestStatus status;
	TInterfaceNotificationBuf info;

	err = OpenSocketServer(ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(ss);

	err = OpenConnection(conn, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(conn);

	err = OpenConnection(activeConn, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(activeConn);

	err = StartConnection(conn);
	TESTEL(KErrNone == err, err);

	// issue request
	AllInterfaceNotification(conn, status, info);

	// start another different connection to complete request if it hasn't already done so
	err = StartConnectionWithOverrides(activeConn, 1);
	TESTEL(KErrNone == err, err);

	// wait for completion
	User::WaitForRequest(status);

	// check for correct value
	TESTEL(status.Int() == KErrInUse, status.Int());

	CloseConnection(activeConn);
	CleanupStack::Pop();

	CloseConnection(conn);
	CleanupStack::Pop();

	CloseSocketServer(ss);
	CleanupStack::Pop();

	return TestStepResult();

} // TE_RConnectionTest300
// creates a connection and destroys it again
enum TVerdict TE_RConnectionTest304::doTestStepL(void)
{
	TInt err;

	RSocketServ socketServer;
	RConnection connection;
	RConnection monitor;

	TRequestStatus status;
	TInterfaceNotificationBuf info;

	err = OpenSocketServer(socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(socketServer);

	err = OpenConnection(connection, socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(connection);

	err = OpenConnection(monitor, socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(monitor);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	// start connection to complete request
	err = StartConnection(connection);
	TESTEL(KErrNone == err, err);

	CheckInterfaceNotificationL(status, info, EInterfaceUp, &connection);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	CloseConnection(connection);
	CleanupStack::Pop();

	CheckInterfaceNotificationL(status, info, EInterfaceDown);

	CloseConnection(monitor);
	CleanupStack::Pop();

	CloseSocketServer(socketServer);
	CleanupStack::Pop();

	return TestStepResult();

} // TE_RConnectionTest304
int CParserDownloader::Start()
{
	VerifyTempFolderExist();

	if(m_connInfo.m_nDlNow <= 0)
	{
		StartConnection();
	}
	else
	{
		m_connInfo.m_nRetry = 0;
		RestartConnection(CCommonUtils::INT_OPER_KEEP, CCommonUtils::MAX_INTEGER);
	}

	return DoDownload();
}
Exemple #10
0
void CServerBrowser::ConnectToSelectedServer( void )
{
	// Get the server list type
	ServerBrowserType type = GetCurrentServerBrowserType();

	// Reset saved password
	m_strServerPassword.clear ();

	// Did we select a server?
	if( m_pServerGridList[ type ]->GetSelectedCount() > 0 )
	{
		// Get the selected row
		int iSelectedRow = m_pServerGridList[ type ]->GetSelectedItemRow();

		// Get the server ip and port
		char* szIp = m_pServerGridList[ type ]->GetItemText( iSelectedRow, 6 );
		int iPort = atoi( m_pServerGridList[ type ]->GetItemText( iSelectedRow, 7 ) );

		// Get the server list item?
		m_pSelectedServer = m_pServerList[ type ]->GetItem ( szIp, iPort );
	}

	// Is the item valid?
	if ( m_pSelectedServer )
	{
		// Is the server password protected?
		if ( m_pSelectedServer->bPassworded )
		{
			// Show the password window
			m_pServerPassword->SetVisible ( true );
		}
		else
		{
			// Store the server ip and port
			m_strServerIP = m_pSelectedServer->strHost;
			m_iServerPort = m_pSelectedServer->usGamePort;

			// Start the connection
			StartConnection ();

			// Reset the selected server
			m_pSelectedServer = NULL;
		}
	}
}
Exemple #11
0
void StartRecentLookupsRequest(AppContext* appContext)
{
    if (!HasCookie(appContext->prefs))
        FrmAlert(alertNoLookupsYet);
    else 
    {
        ExtensibleBuffer urlBuffer;
        ebufInit(&urlBuffer, 0);
        Err error=PrepareGenericRequest(appContext->prefs.cookie, recentLookupsRequestParam, urlBuffer);
        if (!error) 
        {
            const char* requestUrl=ebufGetDataPointer(&urlBuffer);
            StartConnection(appContext, NULL, requestUrl, GeneralStatusTextRenderer,
                RecentLookupsResponseProcessor, NULL);
        }
        else 
            FrmAlert(alertMemError);
        ebufFreeData(&urlBuffer);
    }
}
Exemple #12
0
void StartCookieRequestWithRegistration(AppContext* appContext, const char* serialNumber)
{
    ExtensibleBuffer request;
    ebufInit(&request, 0);
    Err error=CookieRequestPrepareRequest(request);
    if (!error)
    {
        ExtensibleBuffer* snBuffer=ebufNew();
        if (snBuffer)
        {
            ebufInitWithStr(snBuffer, const_cast<char*>(serialNumber));
            ebufAddChar(snBuffer, chrNull);
            StartConnection(appContext, snBuffer, ebufGetDataPointer(&request), GeneralStatusTextRenderer, 
                CookieRequestResponseProcessorWithRegistration, CookieRequestContextDestructor);
        }
        else
            FrmAlert(alertMemError);
    }
    else
        FrmAlert(alertMemError);    
    ebufFreeData(&request);
}
// creates a connection and destroys it again
enum TVerdict TE_RConnectionTest308::doTestStepL(void)
{
	TInt err;
	TInt i;

	RSocketServ socketServer;
	RConnection connection;

	RConnection monitor[ KTS308_NoofMonitors ];
	TRequestStatus status[ KTS308_NoofMonitors ];
	TInterfaceNotificationBuf info[ KTS308_NoofMonitors ];

	err = OpenSocketServer(socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(socketServer);

	err = OpenConnection(connection, socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(connection);

	for( i = 0; i < KTS308_NoofMonitors; i++ )
		{
		err = OpenConnection(monitor[i], socketServer);
		TESTEL(KErrNone == err, err);
		CleanupClosePushL(monitor[i]);
		}

	// issue requests
	for( i = 0; i < KTS308_NoofMonitors; i++ )
		{
		AllInterfaceNotification(monitor[i], status[i], info[i]);
		}

	// start connection to complete request
	err = StartConnection(connection);
	TESTEL(KErrNone == err, err);

	// check for interface up...
	for( i = 0; i < KTS308_NoofMonitors; i++ )
		{
		CheckInterfaceNotificationL(status[i], info[i], EInterfaceUp, &connection);
		}

	// issue requests
	for( i = 0; i < KTS308_NoofMonitors; i++ )
		{
		AllInterfaceNotification(monitor[i], status[i], info[i]);
		}

	CloseConnection(connection);
	CleanupStack::Pop();

	// check for interface down...
	for( i = 0; i < KTS308_NoofMonitors; i++ )
		{
		CheckInterfaceNotificationL(status[i], info[i], EInterfaceDown, NULL);
		}

	// close monitors
	for( i = 0; i < KTS308_NoofMonitors; i++ )
		{
		CloseConnection(monitor[i]);
		CleanupStack::Pop();
		}

	CloseSocketServer(socketServer);
	CleanupStack::Pop();

	return TestStepResult();

} // TE_RConnectionTest308
//*****************************************************************************
//! Receives a TCP packet from lwIP for the telnet server.
//!
//! \param arg is the telnet state data for this connection.
//! \param pcb is the pointer to the TCP control structure.
//! \param p is the pointer to the pbuf structure containing the packet data.
//! \param err is used to indicate if any errors are associated with the
//! incoming packet.
//!
//! This function is called when the lwIP TCP/IP stack has an incoming packet
//! to be processed.
//!
//! \return This function will return an lwIP defined error code.
//*****************************************************************************
err_t TelnetReceive(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
    tState *pState = arg;
    SYS_ARCH_DECL_PROTECT(lev);

#if 0
    CONSOLE("%u: receive 0x%08x, 0x%08x, 0x%08x, %d\n", pState->ucSerialPort, arg, pcb, p, err);
#else
    CONSOLE("%u: receive error=%d\n", pState->ucSerialPort, err);
#endif

    // Place the incoming packet onto the queue if there is space.
    if((err == ERR_OK) && (p != NULL))
    {
        // This should be done in a protected/critical section.
        SYS_ARCH_PROTECT(lev);

        // Do we have space in the queue?
        int iNextWrite = ((pState->iBufQWrite + 1) % PBUF_POOL_SIZE);
        if(iNextWrite == pState->iBufQRead)
        {
            // The queue is full - discard the pbuf and return since we can't handle it just now.
            CONSOLE("%u: WARNING queue is full - discard data\n", pState->ucSerialPort);

            // Restore previous level of protection.
            SYS_ARCH_UNPROTECT(lev);

            // Free up the pbuf.  Note that we don't acknowledge receipt of
            // the data since we want it to be retransmitted later.
            pbuf_free(p);
        }
        else
        {
            // Place the pbuf in the circular queue.
            pState->pBufQ[pState->iBufQWrite] = p;

            // Increment the queue write index.
            pState->iBufQWrite = iNextWrite;

            // Restore previous level of protection.
            SYS_ARCH_UNPROTECT(lev);
        }
    }

    // If a null packet is passed in, close the connection.
    else if((err == ERR_OK) && (p == NULL))
    {
        CONSOLE("%u: received NULL packet - close connection\n", pState->ucSerialPort);

        // Clear out all of the TCP callbacks.
        tcp_arg(pcb, NULL);
        tcp_sent(pcb, NULL);
        tcp_recv(pcb, NULL);
        tcp_err(pcb, NULL);
        tcp_poll(pcb, NULL, 1);

        // Close the TCP connection.
        err = tcp_close(pcb);
        if (err != ERR_OK)
        {
           WARNING("%u: TelnetReceive.tcp_close failed, error=%d\n", pState->ucSerialPort, err);
           ErrorTCPOperation(pState->ucSerialPort, err, TCP_CLOSE_RECEIVE);
        }

        // Clear out any pbufs associated with this session.
        TelnetFreePbufs(pState);

        // Clear out the telnet session PCB.
        pState->pConnectPCB = NULL;

        StartConnection(pState->ucSerialPort);
    }

    CustomerSettings1_TelnetReceive(pState->ucSerialPort);

    return(ERR_OK);
}