Beispiel #1
0
int SSLSocket::read(void *buffer, unsigned long size) {
    ssl_internal_stack *stack;
    stack = (ssl_internal_stack *)idata;
    if(SSL_pending(stack->ssl) == 0) {
        ((char *)buffer)[0] = 0;
        return 0;
    }
    int ret;
    if((ret = SSL_read(stack->ssl, buffer, size)) <= 0) {
        switch(SSL_get_error(stack->ssl, ret)) {
        case SSL_ERROR_ZERO_RETURN:
            throw SSLConnectionClosed();
            break;
        case SSL_ERROR_WANT_WRITE:
        case SSL_ERROR_WANT_READ:
            throw SSLConnectionIsBusy();
            break;
        case SSL_ERROR_WANT_CONNECT:
        case SSL_ERROR_WANT_ACCEPT:
            throw NotConnected();
            break;
        case SSL_ERROR_WANT_X509_LOOKUP:
            throw CertificateLookupPending();
            break;
        case SSL_ERROR_SYSCALL:
        case SSL_ERROR_SSL:
            throw SSLGeneric();
            break;
        }
    }
    return ret;
}
Beispiel #2
0
EXPORT_C void CPolicyServer::ProcessL(const RMessage2& aMsg)
	{
	aMsg.SetAuthorised();
	TInt fn = aMsg.Function();

	if(fn >= 0)
		{
		CSession2* session=aMsg.Session();
		if(session)
			{
			session->ServiceL(aMsg);
			}
		else
			{
			NotConnected(aMsg);
			}
		}
	else if(fn==RMessage2::EConnect)
		{
		Connect(aMsg);
		}
	else if(fn==RMessage2::EDisConnect)
		{
		Disconnect(aMsg);
		}
	else
		{
		BadMessage(aMsg);
		}
	}
// 执行查询操作
void ConnectorMySQL::exec_select(const std::string &command, ErrorCode &error_code, std::vector<char> &result)
{
    result.clear();
    error_code.clear();
    
    if (is_connected())
    {
        mysql_real_query(&mysql_, command.data(), (unsigned long)command.size());
        int error = mysql_errno(&mysql_);
        if (error != 0)
        {
            error_code.code = error;
            error_code.message = mysql_error(&mysql_);
            return;
        }

        if (!SerializeInterface<MYSQL>::serialize_result(mysql_, result))
        {
            error_code.code = mysql_errno(&mysql_);
            error_code.message = mysql_error(&mysql_);
        }
    }
    else
    {
        throw NotConnected();
    }
}
Beispiel #4
0
void SSLSocket::write(const void *buffer, unsigned long size) {
    ssl_internal_stack *stack;
    stack = (ssl_internal_stack *)idata;
    int ret;
    if((ret = SSL_write(stack->ssl, buffer, size)) <= 0) {
        switch(SSL_get_error(stack->ssl, ret)) {
        case SSL_ERROR_ZERO_RETURN:
            throw SSLConnectionClosed();
            break;
        case SSL_ERROR_WANT_READ:
        case SSL_ERROR_WANT_WRITE:
            throw SSLConnectionIsBusy();
            break;
        case SSL_ERROR_WANT_CONNECT:
        case SSL_ERROR_WANT_ACCEPT:
            throw NotConnected();
            break;
        case SSL_ERROR_WANT_X509_LOOKUP:
            throw CertificateLookupPending();
            break;
        case SSL_ERROR_SYSCALL:
        case SSL_ERROR_SSL:
            throw SSLGeneric();
            break;
        }
    }
}
Beispiel #5
0
/**
Handles the receipt of a message.
*/
EXPORT_C void CServer2::RunL()
	{
	TInt fn = Message().Function();

	if(fn>=0)
		{
		// Service the message
		CSession2* session=Message().Session();
		if(session)
			session->ServiceL(Message());
		else
			NotConnected(Message());
		}
	else if(fn==RMessage2::EConnect)
		{
		Connect(Message());
		}
	else if(fn==RMessage2::EDisConnect)
		{
		Disconnect(Message());
		}
	else
		{
		BadMessage(Message());
		}
	// Queue reception of next message if it hasn't already been done
	if(!IsActive())
		ReStart();
	}
Beispiel #6
0
void ConnectorMySQL::SetCharacterSet(const char *csname, ErrorCode &error_code)
{
	if (IsConnected())
	{
		mysql_set_character_set(&mysql_, csname);
		int error = mysql_errno(&mysql_);
		if (error != 0)
		{
			error_code.SetError(error, mysql_error(&mysql_));
		}
	}
	else
	{
		throw NotConnected();
	}
}
Beispiel #7
0
ByteArray ConnectorMySQL::Call(const ByteArray &command, ErrorCode &error_code)
{
	if (IsConnected())
	{
		mysql_real_query(&mysql_, command.data(), command.size());
		int error = mysql_errno(&mysql_);
		if (error != 0)
		{
			error_code.SetError(error, mysql_error(&mysql_));
			return ByteArray();
		}

		ByteArray bytes;
		MYSQL_RES *sql_result = mysql_store_result(&mysql_);
		if (sql_result != nullptr)
		{
			mysql_stuff::Serialize(sql_result, &bytes);
			mysql_free_result(sql_result);
		}
		else
		{
			ProcedureMySQL procedure(command);
			if (procedure.HasVariable())
			{
				ByteArray query_variable = procedure.QueryVariableValue();
				mysql_real_query(&mysql_, query_variable.data(), query_variable.size());
				int error = mysql_errno(&mysql_);
				if (error != 0)
				{
					error_code.SetError(error, mysql_error(&mysql_));
					return ByteArray();
				}

				MYSQL_RES *sql_result = mysql_store_result(&mysql_);
				mysql_stuff::Serialize(sql_result, &bytes);
				mysql_free_result(sql_result);
			}
		}
		return bytes;
	}
	else
	{
		throw NotConnected();
	}
}
// 设置字符集
void ConnectorMySQL::set_character_set(const char *csname, ErrorCode &error_code)
{
    error_code.clear();

    if (is_connected())
    {
        mysql_set_character_set(&mysql_, csname);
        int error = mysql_errno(&mysql_);
        if (error != 0)
        {
            error_code.code = error;
            error_code.message = mysql_error(&mysql_);
        }
    }
    else
    {
        throw NotConnected();
    }
}
Beispiel #9
0
void ConnectorMySQL::SelectDatabase(const char *db, ErrorCode &error_code)
{
	if (IsConnected())
	{
		mysql_select_db(&mysql_, db);
		int error = mysql_errno(&mysql_);
		if (error == 0)
		{
			select_db_ = db;
		}
		else
		{
			error_code.SetError(error, mysql_error(&mysql_));
		}
	}
	else
	{
		throw NotConnected();
	}
}
Beispiel #10
0
ByteArray ConnectorMySQL::Insert(const ByteArray &command, ErrorCode &error_code)
{
	if (IsConnected())
	{
		mysql_real_query(&mysql_, command.data(), command.size());
		int error = mysql_errno(&mysql_);
		if (error != 0)
		{
			error_code.SetError(error, mysql_error(&mysql_));
			return ByteArray();
		}

		ByteArray bytes;
		mysql_stuff::SerializeAffectedRowsAndInsertID(mysql_, &bytes);
		return bytes;
	}
	else
	{
		throw NotConnected();
	}
}
// 选择数据库
void ConnectorMySQL::select_db(const char *db, ErrorCode &error_code)
{
    error_code.clear();

    if (is_connected())
    {
        mysql_select_db(&mysql_, db);
        int error = mysql_errno(&mysql_);
        if (error == 0)
        {
            select_db_ = db;
        }
        else
        {
            error_code.code = error;
            error_code.message = mysql_error(&mysql_);
        }
    }
    else
    {
        throw NotConnected();
    }
}
Beispiel #12
0
ByteArray ConnectorMySQL::Select(const ByteArray &command, ErrorCode &error_code)
{
	if (IsConnected())
	{
		mysql_real_query(&mysql_, command.data(), command.size());
		int error = mysql_errno(&mysql_);
		if (error != 0)
		{
			error_code.SetError(error, mysql_error(&mysql_));
			return ByteArray();
		}

		ByteArray bytes;
		MYSQL_RES *sql_result = mysql_store_result(&mysql_);
		mysql_stuff::Serialize(sql_result, &bytes);
		mysql_free_result(sql_result);
		return bytes;
	}
	else
	{
		throw NotConnected();
	}
}
void CProblemSolver::TryToDetectBeginnersProblems()
{
	if (NoTableMapsInScraperFolder())
	{
		OH_MessageBox_Interactive(
			"BAD NEWS:\n"
			"    - No tablemaps in scraper folder.\n"
			"\n"
			"You need a tablemap for every casino and game-type.",
			k_title_string, 0);

	}
	else if (NotConnected())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n"
			"\n"
			"BAD NEWS:\n"
			"    - You are not connected to a table.\n"
			"\n"
			" To connect to a table three conditions must be met:\n"
			"    - You need a tablemap for that casino and game-type.\n"
			"    - The table must match z$clientsizemin and z$clientsizemax.\n"
      "         OpenScrape -> Menu -> View\n"
			"    - The s$titletext must match.\n"
			"If OpenHoldem does not connect, then you have to fix your tablemap.",
			k_title_string, 0);
	}
	else if (NoOpponents())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n."
			"    - You are connected to a table.\n"
			"\n"
			"BAD NEWS:\n"
			"    - There seem to be no opponents.\n"
			"\n"
			"Please revisit your tablemap, especially:\n"
			"    - Seated regions\n"
			"    - Active regions\n"
			"    - Cardbacks\n",
			k_title_string, 0);
	}
	else if (UserChairUnknown())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n"
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"\n"
			"BAD NEWS:\n"
			"    - You are not seated or userchair not (yet) recognized.\n"
			"\n"
			"To detect the userchair three conditions must be met:\n"
			"    - Player must be active (not sitting out).\n"
			"    - Cards visible.\n"
			"    -  Buttons visible at the same time.\n"
			"Please revisit your tablemap.",
			k_title_string, 0);
	}
	else if (AutoPlayerDidActAtLeastOnce())
	{
		// This is the GOOD case!
		OH_MessageBox_Interactive(
			"REALLY GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n"
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized.\n"
			"    - The autoplayer did act at least once.\n"
			"\n"
			"This means that your map and your settings\n"
			"are at least not completely wrong.\n" 
			"The rest is fine-tuning,\n"
			"we won't deal with that here.\n"
			"\n"
			"Good luck, dear friend.\n",
			k_title_string, 0);
	}
	// Cards and buttons get handled after the good case,
	// because cards and buttons are not always visible,
	// even if everything is ok.
	else if (NoCardsVisible())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder\n."
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized.\n"
			"\n"
			"BAD NEWS:\n"
			"    - You don't have any cards\n"
			"\n"       
			"Please revisit your tablemap\n"
			"to make sure that cards get scraped correctly.",
			k_title_string, 0);
	}
	else if (NotEnoughButtonsVisible())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder\n."
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized.\n"
			"    - Your cards got recognized.\n"
			"\n"
			"BAD NEWS:\n"
			"    - Not enough buttons detected.\n"
			"\n"       
			"Please revisit your tablemap\n"
			"to make sure that all buttons get scraped correctly.",     
			k_title_string, 0);
	}
	else
	{
		// This should not happen.
		// No error detected, but autoplayer did not yet act.
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder\n."
			"    - You are connected to a table\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized\n"
			"    - Your cards got recognized\n"
			"    - Buttons got detected\n"
			"\n"
			"BAD NEWS:\n"
			"    - The autoplayer did not (yet) act,\n"        
			"\n"
			"The autoplayer should act within some seconds,\n"
			"as long as the autoplayer is engaged (default).\n",
			k_title_string, 0);
	}
}
Beispiel #14
0
TEST(BasicConnectDelay, NotConnected)
{
  NotConnected();
}
Beispiel #15
0
TEST(BasicConnect, NotConnected)
{
  NotConnected();
}