예제 #1
0
void PopSession::ConnectFailure(MailError::ErrorCode errCode, const std::string& errMsg)
{
	// skip to not_ok_to_sync state
	m_state = State_CancelPendingCommands;
	SetError(errCode, errMsg);
	CheckQueue();
}
예제 #2
0
void PopSession::ShutdownConnection() {
	// shutting down connection
	if (m_connection.get()) {
		m_connection->Shutdown();
	}

	// TODO: should do the following actions in a callback function to socket's WatchClosed() function
	// reset line reader, input/output streem and connection.
	m_lineReader.reset(NULL);
	m_inputStream.reset(NULL);
	m_outputStream.reset(NULL);
	m_connection.reset(NULL);
	// reset UID map
	m_uidMap.reset(new UidMap());

	// once disconnected, change the state to need connection
	m_state = State_NeedsConnection;

	// mark the pop session as disconnected
	if(m_reconnect && m_commandManager->GetPendingCommandCount()>0) {
		m_reconnect = false;
		CheckQueue();
	} else {
		Disconnected();
	}
}
예제 #3
0
void PopSession::FetchEmail(Request::RequestPtr request)
{
	MojLogInfo(m_log, "Fetching email '%s' with '%s' priority", AsJsonString(request->GetEmailId()).c_str(), ((request->GetPriority() == Request::Priority_High) ? "high" : "low"));
	MojRefCountedPtr<FetchEmailCommand> command(new FetchEmailCommand(*this, request));
	m_commandManager->QueueCommand(command, (request->GetPriority() == Request::Priority_High));
	CheckQueue();
}
MessageQueue::~MessageQueue()
{
	char *message;

	while (CheckQueue(&message))
		delete [] message;
}
예제 #5
0
void PopSession::SyncCompleted()
{
	if (m_state == State_SyncingEmails) {
		m_state = State_OkToSync;
	}
	ResetError();
	CheckQueue();
}
예제 #6
0
void PopSession::LoginFailure(MailError::ErrorCode errorCode, const std::string& errorMsg)
{
	// update account status
	MojLogInfo(m_log, "Login failure for account '%s': %s", AsJsonString(m_account->GetAccountId()).c_str(), errorMsg.c_str());
	// updating 'm_accountError' will be done inside the following call.
	PersistFailure(errorCode, errorMsg);

	m_state = State_CancelPendingCommands;
	CheckQueue();
}
예제 #7
0
void PopSession::AutoDownloadEmails(const MojObject& folderId)
{
	if (m_state == State_SyncingEmails || m_state == State_OkToSync) {
		m_state = State_OkToSync;

		MojLogDebug(m_log, "Creating command to auto download email bodies for folder '%s'", AsJsonString(folderId).c_str());
		MojRefCountedPtr<AutoDownloadCommand> command(new AutoDownloadCommand(*this, folderId));
		m_commandManager->QueueCommand(command);
		CheckQueue();
	}
}
예제 #8
0
void PopSession::LoginSuccess()
{
	if (HasLoginError() || HasRetryAccountError()) {
		// clear account's login error since we pass in a non-error code and message.
		MojLogInfo(m_log, "Clearing login failure status from email account");
		// updating 'm_accountError' will be done inside the following call.
		UpdateAccountStatus(m_account, MailError::VALIDATED, "");
	}

	m_state = State_NeedUidMap;
	CheckQueue();
}
예제 #9
0
/**
  Check key buffer to get the key stroke status.

  @param  This         Pointer of the protocol EFI_SIMPLE_TEXT_IN_PROTOCOL.

  @retval EFI_SUCCESS  A key is being pressed now.
  @retval Other        No key is now pressed.

**/
EFI_STATUS
EFIAPI
VirtualKeyboardCheckForKey (
  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This
  )
{
  VIRTUAL_KEYBOARD_DEV     *VirtualKeyboardPrivate;

  VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);

  return CheckQueue (&VirtualKeyboardPrivate->Queue);
}
MessageQueue::~MessageQueue()
{
	unsigned char *message;
    int length;

	while (CheckQueue( &message, &length ))
	{
        if (message && length > 0)
        {
            delete [] message;
        }
	}
}
예제 #11
0
파일: rQueue.cpp 프로젝트: kaina/sandbox
ULONG ROQueue::Worker()
{
	::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_LOWEST);
	::SuspendThread(::GetCurrentThread());

	while (m_Terminate==false)
	{
		CheckQueue();

		::SwitchToThread();
		::Sleep(800);
	}

	return 0;
}
예제 #12
0
/**
  Reads the next keystroke from the input device. The WaitForKey Event can
  be used to test for existance of a keystroke via WaitForEvent () call.

  @param  VirtualKeyboardPrivate   Virtualkeyboard driver private structure.
  @param  KeyData                  A pointer to a buffer that is filled in
                                   with the keystroke state data for the key
                                   that was pressed.

  @retval EFI_SUCCESS              The keystroke information was returned.
  @retval EFI_NOT_READY            There was no keystroke data availiable.
  @retval EFI_DEVICE_ERROR         The keystroke information was not returned
                                   due to hardware errors.
  @retval EFI_INVALID_PARAMETER    KeyData is NULL.

**/
EFI_STATUS
KeyboardReadKeyStrokeWorker (
  IN VIRTUAL_KEYBOARD_DEV  *VirtualKeyboardPrivate,
  OUT EFI_KEY_DATA      *KeyData
  )
{
  EFI_STATUS                            Status;
  EFI_TPL                               OldTpl;
  if (KeyData == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Use TimerEvent callback function to check whether there's any key pressed
  //

  //
  // Stall 1ms to give a chance to let other driver interrupt this routine for
  // their timer event.
  // e.g. OS loader, other drivers which are driven by timer event will have a
  // bad performance during this period,
  // e.g. usb keyboard driver.
  // Add a stall period can greatly increate other driver performance during
  // the WaitForKey is recursivly invoked. 1ms delay will make little impact
  // to the thunk keyboard driver, and user can not feel the delay at all when
  // input.
  //
  gBS->Stall (1000);

  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);

  VirtualKeyboardTimerHandler (NULL, VirtualKeyboardPrivate);
  //
  // If there's no key, just return
  //
  Status = CheckQueue (&VirtualKeyboardPrivate->Queue);
  if (EFI_ERROR (Status)) {
    gBS->RestoreTPL (OldTpl);
    return EFI_NOT_READY;
  }

  Status = Dequeue (&VirtualKeyboardPrivate->Queue, KeyData);

  gBS->RestoreTPL (OldTpl);

  return EFI_SUCCESS;
}
예제 #13
0
void PopSession::SyncFolder(const MojObject& folderId, bool force)
{
	MojLogInfo(m_log, "PopSession %p: inbox=%s, syncing folder=%s, force=%d", this,
			AsJsonString(m_account->GetInboxFolderId()).c_str(), AsJsonString(folderId).c_str(), force);
	if (folderId != m_account->GetInboxFolderId()) {
		// POP transport only supports inbox sync.
		MojLogInfo(m_log, "PopSession %p will skip non-inbox syncing", this);
		return;
	}

	if (m_state == State_AccountDisabled || m_state == State_AccountDeleted) {
		MojLogInfo(m_log, "Cannot sync an inbox of disabled/deleted account");
		return;
	}

	if (force) {
		// TODO: kills existing inbox sync
		if (HasLoginError() || HasRetryAccountError() || HasNetworkError()) {
			// In State_Connecting means the socket was just reconnected.
			// We don't want to force reconnection again.
			if(m_state != State_Connecting) {
				m_state = State_NeedsConnection;
			}
		}
	} else if (HasLoginError()) {
		MojLogInfo(m_log, "Cannot sync inbox of an account with invalid credentials");
		if (m_syncSession.get()) {
			m_syncSession->RequestStop();
		}
		return;
	} else if (m_state == State_SyncingEmails) {
		MojLogDebug(m_log, "Already syncing inbox emails.");
		return;
	}

	if (m_state == State_NeedsConnection) {
		m_commandManager->Pause();
	}

	MojLogInfo(m_log, "Creating SyncEmailsCommand");
	MojRefCountedPtr<SyncEmailsCommand> command(new SyncEmailsCommand(*this, folderId, m_uidMap));
	m_syncSession->RequestStart();
	m_requestManager->RegisterCommand(command);
	m_commandManager->QueueCommand(command);

	CheckQueue();
}
예제 #14
0
void PopSession::Connected()
{
	if (m_account->GetEncryption() == PopAccount::SOCKET_ENCRYPTION_TLS) {
		m_state = State_CheckTlsSupport;
	} else {
		m_state = State_UsernameRequired;
	}

	// if there was an connection error, reset it
	if (HasNetworkError()) {
		ResetError();
	}

	MojLogInfo(m_log, "Connected to POP server. Need to send username.");

	CheckQueue();
}
예제 #15
0
void MT_HIDGamePad::Poll()
{
#ifdef MT_GAMEPAD_MAC
    // Check the queue for button presses
    CheckQueue();
    PollXAxis();
    PollYAxis();
    PollZAxis();
    PollWAxis();
#elif defined MT_GAMEPAD_USE_WX
    ButtonStates = myJoystick.GetButtonState();
    wxPoint XYpt = myJoystick.GetPosition();
    X = XYpt.x;
    Y = XYpt.y;
    Xf = (((float) X) - xcenter)*xnorm;
    Yf = (((float) Y) - ycenter)*ynorm;
    W = myJoystick.GetRudderPosition();
    Z = myJoystick.GetZPosition();
    Wf = (((float) W) - wcenter)*wnorm;
    Zf = (((float) Z) - zcenter)*znorm;

    // gamepadcontroller expects a number from -128 to 128
    X = (int) (128.0*Xf);
    Y = (int) (128.0*Yf);
    Z = (int) (128.0*Zf);
    W = (int) (128.0*Wf);

    //printf("%d, %d, %d, %d, %f, %f, %f, %f\n", X, Y, W, Z, Xf, Yf, Wf, Zf);

#endif  // MT_GAMEPAD_USE_WX

    PollHatState();
    PollU2State();
    PollU3State();
    PollU4State();
}
예제 #16
0
void PopSession::Validate()
{
	CheckQueue();
}
예제 #17
0
void PopSession::DisableAccount(MojServiceMessage* msg)
{
	m_state = State_AccountDisabled;
	CheckQueue();
}
예제 #18
0
void PopSession::TlsSupported()
{
	m_state = State_NegotiateTlsConnection;
	CheckQueue();
}
예제 #19
0
void PopSession::TlsNegotiated()
{
	m_state = State_UsernameRequired;
	CheckQueue();
}
예제 #20
0
void PopSession::TlsFailed()
{
	MojLogInfo(m_log, "Failed to turn on TLS on socket");
	CheckQueue();
}
예제 #21
0
void PopSession::UserOk()
{
	m_state = State_PasswordRequired;
	CheckQueue();
}
예제 #22
0
void PopSession::GotUidMap()
{
	m_state = State_OkToSync;
	MojLogInfo(m_log, "UID map size: %d", m_uidMap->Size());
	CheckQueue();
}
// returns true if message was removed from the Queue
bool MessageQueue::CheckQueue( char **pMessage )
{
    int length;
    return CheckQueue( (unsigned char **) pMessage, &length);
}