Пример #1
0
status_t
IMAPMailbox::StopWatchingMailbox()
{
	if (atomic_get(&fWatching) == 0)
		return B_OK;
	atomic_set(&fWatching, 0);
	return SendRawCommand("DONE");
}
Пример #2
0
status_t
IMAPMailbox::StartWatchingMailbox(sem_id startedSem)
{
	atomic_set(&fWatching, 1);

	bool firstIDLE = true;
	// refresh every 29 min
	bigtime_t timeout = 1000 * 1000 * 60 * 29; // 29 min
	status_t status;
	while (true) {
		int32 commandId = NextCommandId();
		TRACE("IDLE ...\n");
		status = SendCommand("IDLE", commandId);
		if (firstIDLE) {
			release_sem(startedSem);
			firstIDLE = false;
		}
		if (status != B_OK)
			break;

		status = HandleResponse(commandId, timeout, false);
		ProcessAfterQuacks(kIMAP4ClientTimeout);

		if (atomic_get(&fWatching) == 0)
			break;

		if (status == B_TIMED_OUT) {
			TRACE("Renew IDLE connection.\n");
			status = SendRawCommand("DONE");
			if (status != B_OK)
				break;
			// handle IDLE response and more
			status = ProcessCommand("NOOP");
			if (status != B_OK)
				break;
			else
				continue;
		}
		if (status != B_OK)
			break;
	}

	atomic_set(&fWatching, 0);
	return status;
}
bool CslIrcSession::LeaveChannel(const wxString& name,const wxString& reason)
{
    if (!CslIrcEngine::GetThread() || m_state!=STATE_CONNECTED)
        return false;

    CslIrcChannel *channel=FindChannel(name);

    if (!channel)
        return false;

    m_channels.Remove(channel);

    if (!channel->Connected)
        return false;

    wxString command=wxT("PART ")+channel->Name;

    if (!reason.IsEmpty())
        command<<wxT(" :")<<reason;

    return SendRawCommand(command);
}