Пример #1
0
void TdsDatabaseLayer::SetError(int nCode, const wxString& strMessage)
{
  SetErrorCode(TranslateErrorCode(nCode));
  SetErrorMessage(strMessage);

  // We really don't want to throw the exception here since it removes
  //  the ability of the calling code to cleanup any memory usage
  //wxPrintf(_("TdsDatabaseLayer SetError() throwing exception\n"));
  //ThrowDatabaseException();
}
Пример #2
0
/*****************************************************************************
** Procedure:  CJTPhone::OnSetHookswitch
**
** Arguments: 'pReq' - Request object representing this phone request
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the TSPI_phoneSetHookSwitch processing
**               for this service provider. 
**
*****************************************************************************/
bool CJTPhone::OnSetHookswitch(RTSetHookswitch* pRequest, LPCVOID lpBuff)
{
	// Cast our pointer back to an event block
	const CEventBlock* pBlock = static_cast<const CEventBlock*>(lpBuff);

	// If we are in the initial state (i.e. this request has not been processed
	// before by any other thread). Then move the packet to the waiting state so 
	// other threads will not interfere with other events or timers.  This is 
	// guarenteed to be thread-safe and atomic.
	if (pRequest->EnterState(STATE_INITIAL, STATE_WAITING))
	{
		// Validate the state passed
		if (pRequest->GetHookswitchState() == PHONEHOOKSWITCHMODE_ONHOOK ||
			pRequest->GetHookswitchState() == PHONEHOOKSWITCHMODE_MIC)
			CompleteRequest(pRequest, PHONEERR_INVALHOOKSWITCHMODE);
		// Send the command to the switch
		else
			GetDeviceInfo()->DRV_SetHookswitch(this, (pRequest->GetHookswitchState() == PHONEHOOKSWITCHMODE_MICSPEAKER) ? 1 : 0);
	}

	// If we are in the waiting stage (2) then see if we received an event from the
	// switch (vs. an interval timer) and if that event was an ACK/NAK in response
	// to the command we issued.
	else if (pRequest->GetState() == STATE_WAITING && pBlock != NULL)
	{
		// If this is a command response for our SETGAIN, then manage it.
		const CPECommand* peCommand = dynamic_cast<const CPECommand*>(pBlock->GetElement(CPBXElement::Command));
		const CPEErrorCode* pidError = dynamic_cast<const CPEErrorCode*>(pBlock->GetElement(CPBXElement::ErrorCode));
		if (pBlock->GetEventType() == CEventBlock::CommandResponse &&
			peCommand->GetCommand() == CPECommand::SetHookSwitch && pidError != NULL)
		{
			// Complete the request with the appropriate error code.
			TranslateErrorCode(pRequest, pidError->GetError());
			return true;
		}
	}

	// Check to see if our request has exceeded the limit for processing.  If 
	// so, tell TAPI that the request failed and delete the request.
	if (pRequest->GetState() == STATE_WAITING && 
		(pRequest->GetStateTime()+REQUEST_TIMEOUT) < GetTickCount())
		CompleteRequest(pRequest, PHONEERR_OPERATIONFAILED);

	// Let the request fall through to the unsolicited handler where we
	// set all the options concerning the newly found call.
	return false;
	
}// CJTPhone::OnSetHookswitch
void FEditorAnalytics::ReportEvent(FString EventName, FString PlatformName, bool bHasCode, int32 ErrorCode, TArray<FAnalyticsEventAttribute>& ExtraParams)
{
	if( FEngineAnalytics::IsAvailable() )
	{
		const UGeneralProjectSettings& ProjectSettings = *GetDefault<UGeneralProjectSettings>();
		TArray<FAnalyticsEventAttribute> ParamArray;
		ParamArray.Add(FAnalyticsEventAttribute(TEXT("ProjectID"), ProjectSettings.ProjectID.ToString()));
		ParamArray.Add(FAnalyticsEventAttribute(TEXT("Platform"), PlatformName));
		ParamArray.Add(FAnalyticsEventAttribute(TEXT("ProjectType"), bHasCode ? TEXT("C++ Code") : TEXT("Content Only")));
		ParamArray.Add(FAnalyticsEventAttribute(TEXT("ErrorCode"), ErrorCode));
		const FString ErrorMessage = TranslateErrorCode(ErrorCode);
		ParamArray.Add(FAnalyticsEventAttribute(TEXT("ErrorName"), ErrorMessage));
		ParamArray.Append(ExtraParams);

		FEngineAnalytics::GetProvider().RecordEvent( EventName, ParamArray );
	}
}
Пример #4
0
// Don't use string! (see https://github.com/dolphin-emu/dolphin/pull/3143)
s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW)
{
#ifdef _WIN32
	s32 errorCode = WSAGetLastError();
#else
	s32 errorCode = errno;
#endif

	if (ret >= 0)
	{
		WiiSockMan::GetInstance().SetLastNetError(ret);
		return ret;
	}

	INFO_LOG(WII_IPC_NET, "%s failed with error %d: %s, ret= %d",
		caller, errorCode, DecodeError(errorCode), ret);

	s32 ReturnValue = TranslateErrorCode(errorCode, isRW);
	WiiSockMan::GetInstance().SetLastNetError(ReturnValue);

	return ReturnValue;
}
Пример #5
0
/*****************************************************************************
** Procedure:  CJTLine::OnSetAgentState
**
** Arguments: 'pReq' - Request object representing this SetAgentState event 
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the lineSetAgentState processing
**               for this service provider.
**
*****************************************************************************/
bool CJTLine::OnSetAgentState(RTSetAgentState* pRequest, LPCVOID lpBuff)
{
	// Cast our pointer back to an event block
	const CEventBlock* pBlock = static_cast<const CEventBlock*>(lpBuff);
	CTSPIAddressInfo* pAddress = GetAddress(0);

	// If we are in the initial state (i.e. this request has not been processed
	// before by any other thread). Then move the packet to the waiting state so 
	// other threads will not interfere with other events or timers.  This is 
	// guarenteed to be thread-safe and atomic.
	if (pRequest->EnterState(STATE_INITIAL, STATE_WAITING))
	{
		// Fail if there is not an agent logged on at this address.
		if (pAddress->GetCurrentAgentGroupCount() == 0)
		{
			CompleteRequest(pRequest, LINEERR_INVALAGENTID);
			return true;
		}

		// Determine whether we are setting the current state or the next
		// state based on the current status of the address in question. If we
		// have active calls running on the line then we cannot adjust the current
		// state - it is done by the ACD.
		DWORD dwState = (pAddress->GetAddressStatus()->dwNumActiveCalls > 0) ?
				pRequest->GetNextAgentState() : pRequest->GetAgentState();

		// Convert the state to the proper ACD status character
		TCHAR chState = _T('U');
		switch (dwState)
		{
			case LINEAGENTSTATE_READY:				chState = _T('R'); break;
			case LINEAGENTSTATE_WORKINGAFTERCALL:	chState = _T('W'); break;
			case LINEAGENTSTATE_NOTREADY:			chState = _T('N'); break;
			case LINEAGENTSTATE_LOGGEDOFF:			chState = _T('S'); break;
		}

		// If we have a valid state then send it to the switch.
		if (chState != _T('U'))
		{
			const TAgentGroup* pGroup = pAddress->GetCurrentAgentGroup(0);
			_TSP_ASSERTE(pGroup != NULL);
			GetDeviceInfo()->DRV_SetAgentState(this, pGroup->strName, chState);
		}
		else
			CompleteRequest(pRequest, LINEERR_INVALAGENTSTATE);
	}

	// If we are in the waiting stage (2) then see if we received an event from the
	// switch (vs. an interval timer) and if that event was an ACK/NAK in response
	// to the command we issued.
	else if (pRequest->GetState() == STATE_WAITING && pBlock != NULL)
	{
		// If this is a command response for our RELEASECALL, then manage it.
		const CPECommand* peCommand = dynamic_cast<const CPECommand*>(pBlock->GetElement(CPBXElement::Command));
		const CPEErrorCode* pidError = dynamic_cast<const CPEErrorCode*>(pBlock->GetElement(CPBXElement::ErrorCode));
		if (pBlock->GetEventType() == CEventBlock::CommandResponse &&
			peCommand->GetCommand() == CPECommand::AgentState && pidError != NULL)
		{
			// Complete the request with the appropriate error code.
			TranslateErrorCode(pRequest, pidError->GetError());
			return true;
		}
	}

	// Check to see if our request has exceeded the limit for processing.  If 
	// so, tell TAPI that the request failed and delete the request.
	if (pRequest->GetState() == STATE_WAITING && 
		(pRequest->GetStateTime()+REQUEST_TIMEOUT) < GetTickCount())
		CompleteRequest(pRequest, LINEERR_OPERATIONFAILED);

	// Let the request fall through to the unsolicited handler.
	return false;

}// CJTLine::OnSetAgentState
Пример #6
0
/*****************************************************************************
** Procedure:  CJTLine::OnSetAgentGroup
**
** Arguments: 'pReq' - Request object representing this SetAgentGroup event 
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the lineSetAgentGroup processing
**               for this service provider.
**
*****************************************************************************/
bool CJTLine::OnSetAgentGroup(RTSetAgentGroup* pRequest, LPCVOID lpBuff)
{
	// Cast our pointer back to an event block
	const CEventBlock* pBlock = static_cast<const CEventBlock*>(lpBuff);
	CTSPIAddressInfo* pAddress = GetAddress(0);

	// If we are in the initial state (i.e. this request has not been processed
	// before by any other thread). Then move the packet to the waiting state so 
	// other threads will not interfere with other events or timers.  This is 
	// guarenteed to be thread-safe and atomic.
	if (pRequest->EnterState(STATE_INITIAL, STATE_WAITING))
	{
		// Collect the parameters. The agent-id is in the first
		// group entry position, the password is in the second and any groups
		// the agent wants access to are in subsequent entries.
		//
		// Note this is a deviation from the TAPI specification since it has no
		// facility for providing a userid/password for logon which our switch
		// requires. This coded "standard" has been used as a workaround in many
		// commercial TSPs currently in use.
		TString strName = (pRequest->GetCount() > 0) ? pRequest->GetGroup(0)->strName : _T("");
		TString strPassword = (pRequest->GetCount() > 1) ? pRequest->GetGroup(1)->strName : _T("");

		// Gather the group entries
		TDWordArray arrGroups;
		for (unsigned int i = 2; i < pRequest->GetCount(); i++)
			arrGroups.push_back(pRequest->GetGroup(i)->GroupID.dwGroupID1);

		// If this is a logoff request then handle it seperately from the
		// other requests since it is an agent state change to the switch.
		if (pRequest->GetCount() == 0)
		{
			// Fail if there is no agent logged on at this address.
			if (pAddress->GetCurrentAgentGroupCount() == 0)
			{
				CompleteRequest(pRequest, LINEERR_INVALAGENTGROUP);
				return false;
			}
			GetDeviceInfo()->DRV_SetAgentState(this, strName, _T('S'));
		}
		else
		{
			// Validate the parameters - if there is no agent id then fail this
			// request since we cannot log on or change our agent groups without it.
			if (strName.empty())
			{
				const TAgentGroup* pGroup = pAddress->GetCurrentAgentGroup(0);
				if (pGroup != NULL)
					strName = pGroup->strName;
				else
					CompleteRequest(pRequest, LINEERR_INVALAGENTID);
			}
			// Or if too many agent groups are passed (max is 2)
			else if (arrGroups.size() > 2)
				CompleteRequest(pRequest, LINEERR_INVALPARAM);

			// Perform the logon if we haven't failed with an error yet
			if (!pRequest->HaveSentResponse())
			{
				DWORD dwGroup1 = (arrGroups.size() > 0) ? arrGroups[0] : 0;
				DWORD dwGroup2 = (arrGroups.size() > 1) ? arrGroups[1] : 0;

				if ((dwGroup1 > 0 && !GetDeviceInfo()->DoesAgentGroupExist(dwGroup1)) ||
					(dwGroup2 > 0 && !GetDeviceInfo()->DoesAgentGroupExist(dwGroup2)))
					CompleteRequest(pRequest, LINEERR_INVALAGENTGROUP);
				else
					GetDeviceInfo()->DRV_Logon(this, strName, strPassword, dwGroup1, dwGroup2);
			}
		}
	}

	// If we are in the waiting stage (2) then see if we received an event from the
	// switch (vs. an interval timer) and if that event was an ACK/NAK in response
	// to the command we issued.
	else if (pRequest->GetState() == STATE_WAITING && pBlock != NULL)
	{
		// If this is a command response for our RELEASECALL, then manage it.
		const CPECommand* peCommand = dynamic_cast<const CPECommand*>(pBlock->GetElement(CPBXElement::Command));
		const CPEErrorCode* pidError = dynamic_cast<const CPEErrorCode*>(pBlock->GetElement(CPBXElement::ErrorCode));
		if (pBlock->GetEventType() == CEventBlock::CommandResponse &&
			(peCommand->GetCommand() == CPECommand::AgentLogon ||
			peCommand->GetCommand() == CPECommand::AgentState) && pidError != NULL)
		{
			// Complete the request with the appropriate error code.
			TranslateErrorCode(pRequest, pidError->GetError());
			return true;
		}
	}

	// Check to see if our request has exceeded the limit for processing.  If 
	// so, tell TAPI that the request failed and delete the request.
	if (pRequest->GetState() == STATE_WAITING && 
		(pRequest->GetStateTime()+REQUEST_TIMEOUT) < GetTickCount())
		CompleteRequest(pRequest, LINEERR_OPERATIONFAILED);

	// Let the request fall through to the unsolicited handler.
	return false;

}// CJTLine::OnSetAgentGroup
Пример #7
0
ESocketErrors FSocketSubsystemHTML5::GetLastErrorCode()
{
	return TranslateErrorCode(0); 
}
ESocketErrors FSocketSubsystemBSD::GetLastErrorCode()
{
	return TranslateErrorCode(errno);
}
Пример #9
0
/*****************************************************************************
** Procedure:  CJTLine::OnSwapHold
**
** Arguments: 'pReq' - Request object representing this SWAPHOLD event 
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the TSPI_lineSwapHold processing
**               for this service provider.
**
*****************************************************************************/
bool CJTLine::OnSwapHold(RTSwapHold* pRequest, LPCVOID lpBuff)
{
	// Cast our pointer back to an event block
	const CEventBlock* pBlock = static_cast<const CEventBlock*>(lpBuff);
	CTSPICallAppearance* pActiveCall = pRequest->GetActiveCall();
	CTSPICallAppearance* pHeldCall = pRequest->GetHoldingCall();

	// If the holding call is a conference call then we are currently building
	// a conference call and want to swap over to the other party in the conference.
	// Use the first call in the conference itself.
	if (pHeldCall->GetCallType() == CTSPICallAppearance::Conference)
		pHeldCall = dynamic_cast<CTSPIConferenceCall*>(pHeldCall)->GetConferenceCall(0);

	_TSP_ASSERTE(pHeldCall != NULL);

	// If we are in the initial state (i.e. this request has not been processed
	// before by any other thread). Then move the packet to the waiting state so 
	// other threads will not interfere with other events or timers.  This is 
	// guarenteed to be thread-safe and atomic.
	if (pRequest->EnterState(STATE_INITIAL, STATE_WAITING))
		GetDeviceInfo()->DRV_HoldCall(this, pActiveCall);

	// If we are in the waiting stage (2) then see if we received an event from the
	// switch (vs. an interval timer) and if that event was an ACK/NAK in response
	// to the command we issued.
	else if (pRequest->GetState() == STATE_WAITING && pBlock != NULL)
	{
		const CPECommand* peCommand = dynamic_cast<const CPECommand*>(pBlock->GetElement(CPBXElement::Command));
		const CPEErrorCode* pidError = dynamic_cast<const CPEErrorCode*>(pBlock->GetElement(CPBXElement::ErrorCode));

		// Watch for ACK/NAK responses to either a HOLD or RETRIEVE call command
		if (pBlock->GetEventType() == CEventBlock::CommandResponse && pidError != NULL &&
			(peCommand->GetCommand() == CPECommand::HoldCall ||	peCommand->GetCommand() == CPECommand::RetrieveCall))
		{
			// If this is an ACK for our HOLDCALL request then retrieve the other call
			// so that it is now active.
			if (peCommand->GetCommand() == CPECommand::HoldCall && pidError->GetError() == 0)
			{
				// If our held call has a conference owner, then swap it for this new call.
				DWORD dwCallState = pHeldCall->GetCallState();
				if (pHeldCall->GetConferenceOwner())
				{
					// Get the conference owner
					CTSPIConferenceCall* pConfCall = pHeldCall->GetConferenceOwner();

					// Remove the only party from the conference - don't
					// let the conference break down.
					pConfCall->RemoveConferenceCall(pHeldCall, false);

					// Add our new onHold party to the conference. It is still connected 
					// so it is not yet added to the conference array, only setup with 
					// a conference owner.
					pConfCall->AddToConference(pActiveCall);

					// Detach the consultation call since it is now attached 
					// through the conference.
					pActiveCall->DetachCall();
					pConfCall->DetachCall();

					// Change the state of the original call within the
					// conference (which should be CONFERENCED) to
					// onHold so we transition it correctly.
					pHeldCall->SetCallState(LINECALLSTATE_ONHOLD);
				}

				// Change the state of the now holding call to be the state of the 
				// original onHold call itself.  We want to preserve the 
				// transfer/conference state.
				pActiveCall->SetCallState(dwCallState);

				// Retrieve the held call
				GetDeviceInfo()->DRV_RetrieveCall(this, pHeldCall);
			}

			// If this is an ACK response to our RetrieveCall command then complete
			// the request and finish connecting up the calls
			else if (peCommand->GetCommand() == CPECommand::RetrieveCall &&	pidError->GetError() == 0)
			{
				// Re-attach the newly connected call as our consultation call for the conference 
				// so that we will properly monitor it for IDLE.
				if (pActiveCall->GetConferenceOwner())
				{
					pActiveCall->GetConferenceOwner()->AttachCall(pHeldCall);
					pHeldCall->AttachCall(pActiveCall->GetConferenceOwner());
					pHeldCall->SetCallType(CTSPICallAppearance::Consultant);
				}
				CompleteRequest(pRequest, 0);
			}

			// Complete the request with the appropriate error code.
			else
				TranslateErrorCode(pRequest, pidError->GetError());
			return true;
		}
	}

	// Check to see if our request has exceeded the limit for processing.  If 
	// so, tell TAPI that the request failed and delete the request.
	if (pRequest->GetState() == STATE_WAITING && 
		(pRequest->GetStateTime()+REQUEST_TIMEOUT) < GetTickCount())
		CompleteRequest(pRequest, LINEERR_OPERATIONFAILED);

	// Let the request fall through to the unsolicited handler where we
	// set all the options concerning the newly found call.
	return false;

}// CJTLine::OnSwapHold