void FvValueMaskNotifier::Init(const FvUInt32 uiCurState,  const FvUInt32 uiMatchMask)
{
	m_uiMatchMask = uiMatchMask;
	if(IsMatch(uiCurState))
	{
		_SetState(MATCH);
	}
	else
	{
		_SetState(NO_MATCH);
	}
}
Example #2
0
void CUpDownClass::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	if (m_dwStyle & UDS_ARROWKEYS) {
		if (nChar == VK_UP) {
			_Up();
			_SetState(udsUp);
		} else if (nChar = VK_DOWN) {
			_Down();
			_SetState(udsDown);
		}
	}
}
		/*=============================================================================
		-- Updates everything for the ButtonCaption.
		=============================================================================*/
		void ButtonCaption::_Update()
		{
			//if the button's state is DOWN, but MBL is up, then the putton should be released
			if (GetState() == State::DOWN  &&  GetRoot()->GetWindow()->GetInput()->GetButtonState(GMB_Left) == false)
			{
				_SetState(State::RELEASED);
				_SendElementMessageToListeners(ElementEvent::RELEASED);
			}
			else if (GetState() == State::RELEASED)
			{
				_SetState(State::UP);
				_SendElementMessageToListeners(ElementEvent::UP);
			}
		}
Example #4
0
void hmsd_sbstate_init::_On_WM_LBUTTONDOWN( hmsd_wndmsg* pWndMsg ) {
	if ( !pWndMsg || pWndMsg->m_message != WM_LBUTTONDOWN ) {
		assert( FALSE );
		return;
	}
	POINT ptLBtnDown;
	RECT rcBtnStart;
	RECT rcBtnEnd;
	RECT rcBtnThumb;

	ptLBtnDown.x = GET_X_LPARAM( pWndMsg->m_lParam );
	ptLBtnDown.y = GET_Y_LPARAM( pWndMsg->m_lParam );
	_GetBtnStartRect( rcBtnStart );
	_GetBtnEndRect( rcBtnEnd );
	_GetBtnThumbRect( rcBtnThumb );
	//
	_SetLBtnDownPoint( &ptLBtnDown );

	// check if need enter other state.
	if ( ::PtInRect( &rcBtnStart, ptLBtnDown ) ) {
		_SetState( hmsd_scrollbar::EHMSDSBSTATE_PRESS_BTN_START );
		_NotifyLBtnDown( ESBDISTRICT_START_BUTTON );
		return;
	} else if ( ::PtInRect( &rcBtnEnd, ptLBtnDown ) ) {
		_SetState( hmsd_scrollbar::EHMSDSBSTATE_PRESS_BTN_END );
		_NotifyLBtnDown( ESBDISTRICT_END_BUTTON );
		return;
	} else if ( ::PtInRect( &rcBtnThumb, ptLBtnDown ) ) {
		_SetState( hmsd_scrollbar::EHMSDSBSTATE_PRESS_BTN_THUMB );
		_NotifyLBtnDown( ESBDISTRICT_THUMB );
		return;
	} 
	
	//
	RECT rcBlankStart;
	RECT rcBlankEnd;
	if ( _GetBlankStartRect( rcBlankStart ) ) {
		if ( ::PtInRect( &rcBlankStart, ptLBtnDown ) ) {
			_NotifyLBtnDown( ESBDISTRICT_START_BLANK );
			return;
		}
	}
	if ( _GetBlankEndRect( rcBlankEnd ) ) {
		if ( ::PtInRect( &rcBlankEnd, ptLBtnDown ) ) {
			_NotifyLBtnDown( ESBDISTRICT_END_BLANK );
			return;
		}
	}

}
void FvValueRangeNotifier::Init(const FvInt32 iCurrentValue, const FvInt32 iMin, const FvInt32 iMax)
{
	FV_ASSERT_WARNING(iMin <= iMax);
	m_iMin = iMin;
	m_iMax = FvMathTool::Max(iMax, iMin);
	m_iValue = iCurrentValue;
	if(IsMatch(iCurrentValue))
	{
		_SetState(MATCH);
	}
	else
	{
		_SetState(NO_MATCH);
	}
}
Example #6
0
void CUpDownClass::OnTimer(UINT nID)
{
	int iState = udsNone;

	if (::GetCapture() == m_hWnd) {
		if (nID == UDT_PAUSE) {
			::KillTimer(m_hWnd, m_idTimer);
			m_idTimer = ::SetTimer(m_hWnd, UDT_REFRESH, 100, NULL);
		}
		
		RECT rcClient;
		::GetClientRect(m_hWnd, &rcClient);
		POINT pt;
		::GetCursorPos(&pt);
		::ScreenToClient(m_hWnd, &pt);

		if (::PtInRect(&rcClient, pt)) {
			iState = (pt.y < rcClient.bottom / 2) ? udsUp : udsDown;
			if (iState == m_iHit) {
				if (iState == udsUp) {
					_Up();
				} else {
					_Down();
				}
			}
		}
	} else {
		::KillTimer(m_hWnd, m_idTimer);
		m_idTimer = 0;
	}
	_SetState(iState);
}
void hmsd_sbstate_pressbtnarrow::_On_WM_KILLFOCUS( hmsd_wndmsg* pWndMsg ) {
	if ( !pWndMsg || pWndMsg->m_message != WM_KILLFOCUS ) {
		assert( FALSE );
		return;
	}
	_SetLBtnDownPoint( NULL );
	_SetState( hmsd_scrollbar::EHMSDSBSTATE_INIT );
}
Example #8
0
void
FtpClient::SetPassive(bool on)
{
	if (on)
		_SetState(ftp_passive);
	else
		_ClearState(ftp_passive);
}
 void
 SMTPClientConnection::_ProtocolSendUsername()
 {
    String sOut;
    StringParser::Base64Encode(m_sUsername, sOut);      
    _SendData(sOut);
    
    _SetState(SENDPASSWORD);
 }
		/*=============================================================================
		-- Message handling.
		=============================================================================*/
		void ButtonCaption::_SendMessage(Message message)
		{
			switch (message)
			{
			case MBL_DOWN_OVER:
				_SetState(State::DOWN);

			}
		}
   void
   SMTPClientConnection::_SendQUIT()
   {
      // Disconnect from the remote SMTP server.
      m_bSessionEnded = true;

      _SendData("QUIT");
      _SetState(QUITSENT);
   }
   void
   SMTPClientConnection::_ProtocolSendPassword()
   {
      String sOut;
      StringParser::Base64Encode(m_sPassword, sOut);      
      
      _SetState(PASSWORDCHECK);

      _SendData(sOut);
   }
void FvValueMaskNotifier::OnModified(const FvUInt32 oldValue, const FvUInt32 newValue)
{
	if(GetState() == NO_MATCH)
	{
		if(IsMatch(newValue))
		{
			_SetState(MATCH);
			_OnMatch();
		}
	}
	else
	{
		if(!IsMatch(newValue))
		{
			_SetState(NO_MATCH);
			_OnNoMatch();
		}
	}
}
void FvValueRangeNotifier::OnModified(const FvInt32 iOldValue, const FvInt32 iNewValue)
{
	m_iValue = iNewValue;
	if(GetState() == NO_MATCH)
	{
		if(IsMatch(iNewValue))
		{
			_SetState(MATCH);
			_OnMatch();
		}
	}
	else
	{
		if(!IsMatch(iNewValue))
		{
			_SetState(NO_MATCH);
			_OnNoMatch();
		}
	}
}
Example #15
0
void CUpDownClass::OnLButtonUp(UINT nFlags, POINT point)
{
	if (::GetCapture() == m_hWnd)
		::ReleaseCapture();

	if (m_idTimer) {
		::KillTimer(m_hWnd, m_idTimer);
		m_idTimer = 0;
	}
	m_iHit = udsNone;
	_SetState(udsNone);
}
Example #16
0
// MouseOver
bool
TransformBox::MouseOver(BPoint where)
{
	TransformToCanvas(where);

	_SetState(_DragStateFor(where, ZoomLevel()));
	fMousePos = where;
	if (fCurrentState) {
		fCurrentState->UpdateViewCursor(fView, fMousePos);
		return true;
	}
	return false;
}
Example #17
0
void CUpDownClass::OnLButtonDown(UINT nFlags, POINT point)
{
	::SetCapture(m_hWnd);
	RECT rcClient;
	::GetClientRect(m_hWnd, &rcClient);
	if (point.y < (rcClient.bottom / 2)) {
		m_iHit = udsUp;
		_Up();
	} else {
		m_iHit = udsDown;
		_Down();
	}
	m_idTimer = ::SetTimer(m_hWnd, UDT_PAUSE, 500, NULL);

	_SetState(m_iHit);
}
   bool
   SMTPClientConnection::_ProtocolPassswordCheck(int iCode, const String &sServerLine)
   {
      if (!IsPositiveCompletion(iCode))
      {
         // Authentication failed with an permanent error.
         String sErrorMessage = "Authentication error. Server response: " + sServerLine;
         _UpdateAllRecipientsWithError(iCode, sErrorMessage, false);

         _SendQUIT();

         return false;
      }
      
      // The server accepted our authentication.
      _SetState(MAILFROM);
      return true;
     
   }
   void
   SMTPClientConnection::InternalParseData(const AnsiString  &Request)
   {
      LOG_DEBUG("SMTPClientConnection::_ParseASCII()");

      String sData = "RECEIVED: " + Request;
      LOG_SMTP_CLIENT(GetSessionID(), GetIPAddress().ToString(), sData);

      // Below 3 lines is fix of the problem that occurs when the remote server answers
      // with 2 line in his welcome message.
      String sMinus = "-";
      if ((Request.GetLength() > 3) && (Request.GetAt(3) == sMinus.GetAt(0)))
      {
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 1");
         return;
      }

      int lFirstSpace = Request.Find(" ");
   
      AnsiString sFirstWordTemp;
      if (lFirstSpace < 0)
         sFirstWordTemp = Request;
      else
         sFirstWordTemp = Request.Mid(0, lFirstSpace);
      sFirstWordTemp.MakeUpper();
      int iCode = atoi(sFirstWordTemp);

      // We should not update all recipient's if we've just sent a
      // RCPT TO. We should only update the specific one we've just
      // sent to.
      // 
      // Also, we should not update state if we've just sent QUIT to
      // the server. At the time we send QUIT, the message has already
      // been either accepted for delivery and rejected. Any error after
      // this isn't relvat.
      if (m_CurrentState != RCPTTOSENT && m_CurrentState != QUITSENT)
      {
         if (IsPermanentNegative(iCode))
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
         else if (IsTransientNegative(iCode))
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
      }
   
      switch (m_CurrentState)
      {
      case SENDUSERNAME:
         _ProtocolSendUsername();
         break;
      case SENDPASSWORD:
         _ProtocolSendPassword();
         break;
      case PASSWORDCHECK:
         if (!_ProtocolPassswordCheck(iCode, Request))
         {
            // Authentication failed. We have just sent
            // a quit command.
            return;
         }

         break;
      }
      
      if (m_CurrentState == HELO)
      {
         if (iCode == 220)
         {
			   String sComputerName = Utilities::ComputerName(); 
      
            if (m_bUseSMTPAuth)
            {
               _SendData("EHLO " + sComputerName);
               _SetState(EHLOSENT);
            }
            else
            {
               _SendData("HELO " + sComputerName);
               _SetState(HELOSENT);
            }
        
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 2");

            return ;
         }
         else
         {
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 3");
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
      }

      if (m_CurrentState == EHLOSENT)
      {
         // Ask the server to initiate login process.
         _SendData("AUTH LOGIN");
         _SetState(SENDUSERNAME);
         return ;
      }

      if (m_CurrentState == HELOSENT)
      {
         if (IsPositiveCompletion(iCode))
         {
            // --- Server accepted HELO. Go to HEADER/MAILFROM state.
            _SetState(MAILFROM);
         }
	      else
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
         }
      }
   

      if (m_CurrentState == MAILFROM)
      {
         String sFrom = m_pDeliveryMessage->GetFromAddress();
         String sData = "MAIL FROM:<" + sFrom + ">";
         _SendData(sData);
         m_CurrentState = MAILFROMSENT;
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 4");
         return;
      }

      if (m_CurrentState == MAILFROMSENT)
      {
         if (IsPositiveCompletion(iCode))
         {
            // --- Server accepted mail from. Go to header/rcpt to state.
            m_CurrentState = RCPTTO;
         }
         else
         {
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 5");
            _UpdateAllRecipientsWithError(iCode, Request, false);
         }

      }

      if (m_CurrentState == RCPTTO)
      {
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 6");

         shared_ptr<MessageRecipient> pRecipient = _GetNextRecipient();
         if (!pRecipient) 
         {
            _SendQUIT();
            return;
         }
         
         String sRecipient = pRecipient->GetAddress();
         String sData = "RCPT TO:<" + sRecipient + ">";
         _SendData(sData);
         m_CurrentState = RCPTTOSENT;

         return;

      }

      if (m_CurrentState == RCPTTOSENT)
      {
         if (m_iCurRecipient < m_vecRecipients.size())
         {
            if (IsPositiveCompletion(iCode))
            {
               _actualRecipients.insert(m_vecRecipients[m_iCurRecipient]);
            }
            else
            {
               _UpdateRecipientWithError(iCode, Request, m_vecRecipients[m_iCurRecipient], false);
            }
         }

         shared_ptr<MessageRecipient> pRecipient = _GetNextRecipient();
         if (pRecipient)
         {
            // Send next recipient.
            _SendData("RCPT TO:<" + pRecipient->GetAddress() + ">");
            m_CurrentState = RCPTTOSENT;
         }
         else
         {
            if (_actualRecipients.size() == 0)
            {
               _SendQUIT();
               return;
            }
            
            m_CurrentState = DATAQUESTION;
         }
      }

      if (m_CurrentState == DATAQUESTION)
      {
         _SendData("DATA");
         m_CurrentState = DATA;
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 7");
         return;
      }

      if (m_CurrentState == DATA)
      {
         if (IsPositiveIntermediate(iCode))
         {
            // Send the data!
            const String fileName = PersistentMessage::GetFileName(m_pDeliveryMessage);
            LOG_DEBUG("SMTPClientConnection::~_BEFORE SendFile");
            _StartSendFile(fileName);
            LOG_DEBUG("SMTPClientConnection::~_AFTER SendFile");
            return;
         }
      }

      if (m_CurrentState == DATASENT)
      {
            LOG_DEBUG("SMTPClientConnection::~_BEFORE SendQUIT");
         _SendQUIT();
            LOG_DEBUG("SMTPClientConnection::~_AFTER SendQUIT");

         if (IsPositiveCompletion(iCode))
         {
            _UpdateSuccessfulRecipients();
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 9");
            return;
         }
         else
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 10");
         }

         return;
      }

      if (m_CurrentState == QUITSENT)
      {     
         // We just received a reply on our QUIT. Time to disconnect.
         m_bPendingDisconnect = true;
         PostDisconnect();
      }
   }
void FvValueRangeNotifier::Detach()
{
	FvRefNode1::Detach();
	_SetState(NONE);
}
Example #21
0
void FvAura::_DelState(const FvAuraState::Mask& eMask)
{
	FvUInt32 uiState = GetState();
	FvMask::Del(uiState, eMask);
	_SetState(uiState);
}
		/*=============================================================================
		-- Constructor for ButtonCaption.
		=============================================================================*/
		ButtonCaption::ButtonCaption()
		{
			_SetState(State::UP);
			mCaption = "";
		}
Example #23
0
bool GameTroopState::SetUp(const GameNormalPlayer* player)
{
	m_Player = player;
	if (m_Player == NULL)
		return false;

	// wizard
	unsigned int wizardID = m_Player->GetWizardInfo().GetWizardID();
	MkHashStr wizardKey = MkStr(wizardID);
	const MkDataNode* wizardData = GameDataNode::WizardSet->GetChildNode(wizardKey);
	if (wizardData == NULL)
		return false;

	const MkDataNode* baseState = wizardData->GetChildNode(L"BaseState");

	int wizardLvIndex = m_Player->GetWizardInfo().GetWizardLevel() - 1;
	
	int baseHP = 0;
	wizardData->GetData(L"BaseHP", baseHP, 0);

	int levelHP = 0;
	wizardData->GetData(L"LevelHP", levelHP, 0);

	// base
	m_HitPointGage.Initialize(baseHP + wizardLvIndex * levelHP);

	// attack
	_SetState(baseState, GameStateName::Troop::A_BonusAttackPower, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::A_AttackPowerRate, 100, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::A_OnPairBonusAP, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::A_TrippleBonusAP, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::A_FullHouseBonusAP, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::A_FourCardBonusAP, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::A_FiveCardBonusAP, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::A_CriticalDamageRate, 20, 1, 100);
	_SetState(baseState, GameStateName::Troop::A_DrainHPAtFourCard, 0, 0, 100);
	_SetState(baseState, GameStateName::Troop::A_DrainHPAtFiveCard, 0, 0, 100);
	_SetState(baseState, GameStateName::Troop::A_DecayEnemyHPt, 0, 0, 100);

	// defense
	_SetState(baseState, GameStateName::Troop::D_DamageResistance, 5, 0, 100);
	_SetState(baseState, GameStateName::Troop::D_DefensePower, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::D_BonusDRAtRest, 5, 0, 100);
	_SetState(baseState, GameStateName::Troop::D_Toughness, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::D_CritRecoveryAtFourCard, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::D_CritRecoveryAtFiveCard, 0, 0, 0xffff);

	// support
	_SetState(baseState, GameStateName::Troop::S_SupplimentCapacity, 4, 0, 20);
	_SetState(baseState, GameStateName::Troop::S_BonusTransformTime, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::S_HealPower, 100, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::S_PtToGainHeal, 100, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::S_HPtAtRest, 15, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::S_HPtForEveryTurn, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::S_HPtAtLoss, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::S_ViewEnemyInfo, eSTIL_None, eSTIL_None, eSTIL_All);
	_SetState(baseState, GameStateName::Troop::S_WinnerBonusAPR, 100, 0, 0xffff);

	// resource
	_SetState(baseState, GameStateName::Troop::R_RedResWeight, 100, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_GreenResWeight, 100, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_VioletResWeight, 100, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_BlueResWeight, 100, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_VoidResWeight, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_PtToGainRes, 100, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_RPtAtRest, 10, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_RPtForEveryTurn, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_ResSlotSize, 5, 0, 8);
	_SetState(baseState, GameStateName::Troop::R_OnPairPower, 10, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_TripplePower, 20, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_FullHousePower, 40, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_FourCardPower, 45, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_FiveCardPower, 60, 1, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_DecayEnemyRPtAtFourCard, 0, 0, 0xffff);
	_SetState(baseState, GameStateName::Troop::R_DecayEnemyRPtAtFiveCard, 0, 0, 0xffff);

	return true;
}
Example #24
0
void CUpDownClass::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	_SetState(udsNone);
}
Example #25
0
bool
FtpClient::Connect(const string& server, const string& login, const string& passwd)
{
	bool rc = false;
	int code, codeType;
	string cmd, replyString;
	BNetAddress addr;
	
	delete fControl;
	delete fData;
	
	fControl = new BNetEndpoint;

	if (fControl->InitCheck() != B_NO_ERROR)
		return false;

	addr.SetTo(server.c_str(), "tcp", "ftp");
	if (fControl->Connect(addr) == B_NO_ERROR) {
		// read the welcome message, do the login
		
		if (_GetReply(replyString, code, codeType)) {
			if (code != 421 && codeType != 5) {
				cmd = "USER ";
				cmd += login;
				_SendRequest(cmd);

				if (_GetReply(replyString, code, codeType)) {
					switch (code) {
						case 230:	
						case 202:	
							rc = true;
							break;

						case 331:  // password needed
							cmd = "PASS ";
							cmd += passwd;
							_SendRequest(cmd);
							if (_GetReply(replyString, code, codeType)) {
								if (codeType == 2)
									rc = true;
							}
							break;

						default:
							break;
	
					}
				}
			}
		}
	}	

	if (rc == true)
		_SetState(ftp_connected);
	else {
		delete fControl;
		fControl = 0;
	}

	return rc;
}