Beispiel #1
0
void Ctrl::EventLoop0(Ctrl *ctrl)
{
	GuiLock __;
	ASSERT(IsMainThread());
	ASSERT(LoopLevel == 0 || ctrl);
	LoopLevel++;
	LLOG("Entering event loop at level " << LoopLevel << BeginIndent);
	Ptr<Ctrl> ploop;
	if(ctrl) {
		ploop = LoopCtrl;
		LoopCtrl = ctrl;
		ctrl->inloop = true;
	}

	bool quit = false;
	ProcessEvents(&quit);
	while(!EndSession() && !quit && ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount())
	{
//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep");
		SyncCaret();
		GuiSleep(1000);
		if(EndSession()) break;
//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents");
		ProcessEvents(&quit);
//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents");
	}

	if(ctrl)
		LoopCtrl = ploop;
	LoopLevel--;
	LLOG(EndIndent << "Leaving event loop ");
}
void
BluetoothProfileController::Next()
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!mDeviceAddress.IsEmpty());
  MOZ_ASSERT(mProfilesIndex < (int)mProfiles.Length());
  MOZ_ASSERT(mTimer);

  mCurrentProfileFinished = false;

  if (!IsBtServiceAvailable()) {
    EndSession();
    return;
  }

  if (++mProfilesIndex >= (int)mProfiles.Length()) {
    EndSession();
    return;
  }

  BT_LOGR_PROFILE(mProfiles[mProfilesIndex], "");

  if (mConnect) {
    mProfiles[mProfilesIndex]->Connect(mDeviceAddress, this);
  } else {
    mProfiles[mProfilesIndex]->Disconnect(this);
  }
}
Beispiel #3
0
LRESULT CALLBACK Ctrl::OverwatchWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if(msg == WM_USER) {
		ELOGW("WM_USER");
		PostQuitMessage(0);
	}
	if(msg == WM_QUERYENDSESSION) {
		static BOOL (WINAPI *ShutdownBlockReasonCreate)(HWND hWnd, LPCWSTR pwszReason);
		static BOOL (WINAPI *ShutdownBlockReasonDestroy)(HWND hWnd);
		ONCELOCK {
			if(HMODULE hDLL = LoadLibrary ("user32")) {
				AutoCast(ShutdownBlockReasonCreate, GetProcAddress(hDLL, "ShutdownBlockReasonCreate"));
				AutoCast(ShutdownBlockReasonDestroy, GetProcAddress(hDLL, "ShutdownBlockReasonCreate"));
			}
		}
		if(ShutdownBlockReasonCreate)
			ShutdownBlockReasonCreate(hwnd, ~WString(t_("waiting for user response")));
		EndSession();
		ELOGW("WM_QUERYENDSESSION 1");
		OverwatchEndSession.Wait();
		if(ShutdownBlockReasonDestroy)
			ShutdownBlockReasonDestroy(hwnd);
		ELOGW("WM_QUERYENDSESSION 2");
		return TRUE;		
	}
	if(msg == WM_ENDSESSION) {
		EndSession();
		ELOGW("WM_ENDSESSION 1");
		ExitLoopEvent.Set();
		ELOGW("WM_ENDSESSION 2");
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
void
BluetoothProfileController::StartSession()
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!mDeviceAddress.IsEmpty());
  MOZ_ASSERT(mProfilesIndex == -1);
  MOZ_ASSERT(mTimer);

  if (!IsBtServiceAvailable()) {
    EndSession();
    return;
  }

  if (mProfiles.Length() < 1) {
    BT_LOGR("No queued profile.");
    EndSession();
    return;
  }

  if (mTimer) {
    mTimer->InitWithCallback(new CheckProfileStatusCallback(this),
                             CONNECTION_TIMEOUT_MS, nsITimer::TYPE_ONE_SHOT);
  }

  BT_LOGR("%s", mConnect ? "connecting" : "disconnecting");

  Next();
}
Beispiel #5
0
void Ctrl::GuiSleep0(int ms)
{
	GuiLock __;
	ASSERT(IsMainThread());
	ELOG("GuiSleep");
	if(EndSession())
		return;
	ELOG("GuiSleep 2");
	int level = LeaveGuiMutexAll();
#if !defined(flagDLL) && !defined(PLATFORM_WINCE)
	if(!OverwatchThread) {
		DWORD dummy;
		OverwatchThread = CreateThread(NULL, 0x100000, Win32OverwatchThread, NULL, 0, &dummy);
		ELOG("ExitLoopEventWait 1");
		ExitLoopEvent().Wait();
	}
	HANDLE h[1];
	*h = ExitLoopEvent().GetHandle();
	ELOG("ExitLoopEventWait 2 " << (void *)*h);
	MsgWaitForMultipleObjects(1, h, FALSE, ms, QS_ALLINPUT);
#else
	MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT);
#endif
	EnterGuiMutex(level);
}
BOOL CChatSelector::OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch (wParam){ 
		case MP_DETAIL:{
			const CChatItem* ci = GetCurrentChatItem();
			if (ci) {
				CClientDetailDialog dialog(ci->client);
				dialog.DoModal();
			}
			break;
		}
		case MP_ADDFRIEND:{
			const CChatItem* ci = GetCurrentChatItem();
			if (ci && !ci->client->IsFriend() )
				theApp.friendlist->AddFriend(ci->client);
			break;
		}
		case MP_REMOVE:{
			const CChatItem* ci = GetCurrentChatItem();
			if (ci)
				EndSession(ci->client);
			break;
		}
//==>Fix for closed  [cyrex2001]
#ifdef FIX_CLOSED
		default:
			return CClosableTabCtrl::OnCommand(wParam, lParam);
#endif //Fix for closed
//<==Fix for closed [cyrex2001]
	}
	return TRUE;
}
FAnalyticsProviderFlurry::~FAnalyticsProviderFlurry()
{
	if (bHasSessionStarted)
	{
		EndSession();
	}
}
/**
 * Start capturing stats for upload
 * Uses the unique ApiKey associated with your app
 */
bool FAnalyticsProviderET::StartSession(const TArray<FAnalyticsEventAttribute>& Attributes)
{
	UE_LOG(LogAnalytics, Log, TEXT("[%s] AnalyticsET::StartSession"),*APIKey);

	// end/flush previous session before staring new one
	if (bSessionInProgress)
	{
		EndSession();
	}

	FGuid SessionGUID;
	FPlatformMisc::CreateGuid(SessionGUID);
	SessionID = SessionGUID.ToString(EGuidFormats::DigitsWithHyphensInBraces);

	// always ensure we send a few specific attributes on session start.
	TArray<FAnalyticsEventAttribute> AppendedAttributes(Attributes);
	// this is for legacy reasons (we used to use this ID, so helps us create old->new mappings).
	AppendedAttributes.Emplace(TEXT("UniqueDeviceId"), FPlatformMisc::GetUniqueDeviceId());
	// we should always know what platform is hosting this session.
	AppendedAttributes.Emplace(TEXT("Platform"), FString(FPlatformProperties::IniPlatformName()));
	AppendedAttributes.Emplace(TEXT("LegacyURL"), bUsingLegacyAppServer ? TEXT("true") : TEXT("false"));

	RecordEvent(TEXT("SessionStart"), AppendedAttributes);
	bSessionInProgress = true;
	return bSessionInProgress;
}
FAnalyticsProviderFileLogging::~FAnalyticsProviderFileLogging()
{
	if (bHasSessionStarted)
	{
		EndSession();
	}
}
Beispiel #10
0
int main(const int argc, const char* argv[])
{
	ArgInfo arg = {0};
	if ((argc != 2) && (argc != 4)) {
		usage(argv[0]);
		return 2;
	}

	if (!InitProc(&arg, argc, argv + 1)) {
		fprintf(stderr, "Error! Can't Initialization.\n");
		return 1;
	}

	if (argc == 4) {
		printf("%s %s %s的城市代码是:%s\n",
				argv[1], argv[2], argv[3], arg.citycode);
		return 0;
	}

	if (!StartSession(&arg)) {
		fprintf(stderr, "Error! Can't Start Session.\n");
		return 1;
	}

	//Do something
	printf("%s", arg.output);

	EndSession(&arg);
	CleanupProc(&arg, argc);
	return 0;
}
Beispiel #11
0
bool FAnalyticsProviderFileLogging::StartSession(const TArray<FAnalyticsEventAttribute>& Attributes)
{
	if (bHasSessionStarted)
	{
		EndSession();
	}
	SessionId = UserId + TEXT("-") + FDateTime::Now().ToString();
	const FString FileName = AnalyticsFilePath + SessionId + TEXT(".analytics");
	// Close the old file and open a new one
	FileArchive = IFileManager::Get().CreateFileWriter(*FileName);
	if (FileArchive != nullptr)
	{
		FileArchive->Logf(TEXT("{"));
		FileArchive->Logf(TEXT("\t\"sessionId\" : \"%s\","), *SessionId);
		FileArchive->Logf(TEXT("\t\"userId\" : \"%s\","), *UserId);
		FileArchive->Logf(TEXT("\t\"events\" : ["));
		bHasSessionStarted = true;
		UE_LOG(LogFileLoggingAnalytics, Display, TEXT("Session created file (%s) for user (%s)"), *FileName, *UserId);
	}
	else
	{
		UE_LOG(LogFileLoggingAnalytics, Warning, TEXT("FAnalyticsProviderFileLogging::StartSession failed to create file to log analytics events to"));
	}
	return bHasSessionStarted;
}
void Debug::Print(const char* text, bool timestamp)
{
	StartSession();

	if (vaultmplog == NULL)
		return;

	if (timestamp)
	{
		char buf[32];
		GetTimeFormat(buf, sizeof(buf), false);
		fprintf(this->vaultmplog, "[%s] ", buf);
	}

	/*
	char* lpMsgBuf;

	if( FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), ( LPTSTR ) &lpMsgBuf, 0, NULL ) )
	{
		fprintf( this->vaultmplog, "[error: %s(0x%x)] ", lpMsgBuf, GetLastError() );
	}
	*/

	fwrite(text, sizeof(char), strlen(text), this->vaultmplog);
	fputc((int) '\n', this->vaultmplog);

	EndSession();
}
Beispiel #13
0
BOOL CALLBACK MainDlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch (Message)
	{
		case WM_CLOSE:
		{
			EndSession(hWnd);
				return 0;
		}

		case WM_WINDOWPOSCHANGED:
		{
			if (!IsIconic(hWnd))
				GetWindowRect(hWnd, &session.window);
			return 0;
		}

		case WM_COMMAND:
		{
			if (HIWORD(wParam) == BN_CLICKED)
			{
				int old_mode = csd.mode;

				if ((HWND)lParam == hColourSquareModes[LINE_H])
					ccd.mode = csd.mode = SQUARE_MODE_H;
				else if ((HWND)lParam == hColourSquareModes[LINE_S])
					ccd.mode = csd.mode = SQUARE_MODE_S;
				else if ((HWND)lParam == hColourSquareModes[LINE_V])
					ccd.mode = csd.mode = SQUARE_MODE_V;
				else if ((HWND)lParam == hColourSquareModes[LINE_R])
					ccd.mode = csd.mode = SQUARE_MODE_R;
				else if ((HWND)lParam == hColourSquareModes[LINE_G])
					ccd.mode = csd.mode = SQUARE_MODE_G;
				else if ((HWND)lParam == hColourSquareModes[LINE_B])
					ccd.mode = csd.mode = SQUARE_MODE_B;
				else if ((HWND)lParam == hAddToPreviousButton)
					AddCurrentColourToPrevious();
				else if ((HWND)lParam == hLoadPreviousColours)
					LoadPreviousColours(hWnd);
				else if ((HWND)lParam == hSavePreviousColours)
					SavePreviousColours(hWnd);

				session.square_mode = ccd.mode;

				if (old_mode != csd.mode)
					RedrawColourBlocks();
			}
			break;
		}

		case WM_VSCROLL:
		{
			if (LOWORD(wParam) != SB_ENDSCROLL)
				HandleUpDownScroll((HWND)lParam, HIWORD(wParam));
			break;
		}
	}
	 
	return DefWindowProc (hWnd, Message, wParam, lParam);
}
mozSpellChecker::~mozSpellChecker()
{
  if(mPersonalDictionary){
    //    mPersonalDictionary->Save();
    mPersonalDictionary->EndSession();
  }
  mSpellCheckingEngine = nullptr;
  mPersonalDictionary = nullptr;
}
Beispiel #15
0
bool Ctrl::IsWaitingEvent()
{
	GuiLock __;
	if(quit) {
		WhenDisconnect();
		EndSession();
		Exit(0);
	}
	while(socket.Timeout(0).WaitRead()) {
		socket.Timeout(20000);
		String s = websocket.Recieve();
		if(s.IsVoid()) { // No data returned -> means EOF was reached
			WhenDisconnect();
			EndSession();
			Exit(0);
		}
		LLOG("Recieved data " << s);
		StringStream ss(s);
		while(!ss.IsEof()) {
			String s = ss.GetLine();
			CParser p(s);
			try {
				if(p.Id("S")) {
					uint32 l = p.ReadNumber();
					uint32 h = p.ReadNumber();
					recieved_update_serial = MAKEQWORD(l, h);
					stat_client_ms = p.ReadNumber();
				}
				else
					event_queue.AddTail(s);
			}
			catch(CParser::Error) {}
		}
		if(recieved_update_serial == serial_0) {
			serial_0 = 0;
			stat_roundtrip_ms = msecs() - serial_time0;
			serial_time0 = Null;
		}
	}
	socket.Timeout(20000);
	if(socket.IsError())
		LLOG("ERROR: " << socket.GetErrorDesc());
	return event_queue.GetCount();
}
Beispiel #16
0
Pump::Pump(qintptr handle,const QString &Password,QObject *parent):QObject(parent),Password(Password) {
    csock=new SecureSocket(Password,true,this);
    connect(csock,SIGNAL(RecvData(QByteArray)),this,SLOT(ClientRecv(QByteArray)));
    connect(csock,SIGNAL(disconnected()),this,SLOT(EndSession()));
    csock->setSocketDescriptor(handle);
    ssock=NULL;
    usock=NULL;
    CHost=csock->peerAddress();
    CPort=csock->peerPort();
    status=Initiated;
    Log::log(csock,"connection established");
}
Beispiel #17
0
static void
ChooseSessionCancelXtProc(Widget w, XtPointer client_data, XtPointer callData)
{
    if (delete_session_phase > 0 || break_lock_phase > 0)
    {
	XtVaSetValues (chooseSessionMessageLabel,
	    XtNforeground, save_message_background,
            NULL);

	delete_session_phase = 0;
	break_lock_phase = 0;
    }
    else
	EndSession (2);
}
void
BluetoothProfileController::GiveupAndContinue()
{
  MOZ_ASSERT(!mCurrentProfileFinished);
  MOZ_ASSERT(mProfilesIndex < (int)mProfiles.Length());

  BT_LOGR_PROFILE(mProfiles[mProfilesIndex], ERR_OPERATION_TIMEOUT);
  mProfiles[mProfilesIndex]->Reset();

  if (IsBtServiceAvailable()) {
    Next();
  } else {
    EndSession();
  }
}
Beispiel #19
0
LRESULT CALLBACK Ctrl::OverwatchWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if(msg == WM_USER) {
		ELOG("WM_USER");
		PostQuitMessage(0);
	}
	if(msg == WM_ENDSESSION) {
		EndSession() = true;
		ELOG("WM_ENDSESSION 1");
		ExitLoopEvent().Set();
		ELOG("WM_ENDSESSION 2");
		OverwatchEndSession.Wait();
		ELOG("WM_ENDSESSION 3");
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
void Debug::PrintSystem()
{
	StartSession();

	FILE* systeminfo = popen("systeminfo", "r");

	if (systeminfo == NULL)
		return;

	char buf[2048];

	while (fgets(buf, sizeof(buf), systeminfo) != NULL)
		fwrite(buf, sizeof(char), strlen(buf), this->vaultmplog);

	pclose(systeminfo);

	EndSession();
}
Beispiel #21
0
bool Ctrl::ProcessEvent(bool *quit)
{
	if(EndSession())
		return false;
	if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle())
		ReleaseCtrlCapture();
	MSG msg;
	if(PeekMsg(msg)) {
		if(msg.message == WM_QUIT && quit)
			*quit = true;
//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": sProcessMSG " << FormatIntHex(msg.message));
		sProcessMSG(msg);
//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": //sProcessMSG " << FormatIntHex(msg.message));
		DefferedFocusSync();
		SyncCaret();
		return true;
	}
	return false;
}
Beispiel #22
0
LRESULT TopWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	GuiLock __;
	HWND hwnd = GetHWND();
#ifndef PLATFORM_WINCE
	bool inloop;
#endif
	switch(message) {
#ifndef PLATFORM_WINCE
	case WM_QUERYENDSESSION:
		inloop = InLoop();
		WhenClose();
		return inloop ? !InLoop() : !IsOpen();
	case WM_ENDSESSION:
		EndSession() = true;
		PostQuitMessage(0);
		return 0;
#endif
	case WM_CLOSE:
		if(IsEnabled()) {
			IgnoreMouseUp();
			WhenClose();
		}
		return 0;
	case WM_WINDOWPOSCHANGED:
#ifndef PLATFORM_WINCE
		if(IsIconic(hwnd))
			state = MINIMIZED;
		else
		if(IsZoomed(hwnd))
			state = MAXIMIZED;
		else
#endif
		{
			state = OVERLAPPED;
			overlapped = GetScreenClient(hwnd);
		}
		Layout();
		break;
	}
	return Ctrl::WindowProc(message, wParam, lParam);
}
Beispiel #23
0
void Pump::ClientRecv(const QByteArray &Data) {
    switch (status) {
        case Initiated: {
            QVariantMap qvm(QJsonDocument::fromJson(Data).toVariant().toMap()),qvm2;
            if ((!Version::CheckVersion(qvm["version"].toString()))||qvm["password"]!=Password) {
                qvm2.insert("status","no");
                emit csock->SendData(QJsonDocument::fromVariant(qvm2).toJson());
                csock->disconnectFromHost();
                Log::log(csock,"was refused");
                break;
            }
            if (qvm["protocol"]=="TCP") {
                ssock=new TcpSocket(this);
                connect(ssock,SIGNAL(RecvData(QByteArray)),this,SLOT(ServerRecv(QByteArray)));
                connect(ssock,SIGNAL(disconnected()),this,SLOT(EndSession()));
                ssock->connectToHost(qvm["host"].toString(),qvm["port"].toUInt());
                status=TCP;
                Log::log(csock,"requested TCP connection to "+qvm["host"].toString()+':'+QString::number(qvm["port"].toUInt()));
            } else if (qvm["protocol"]=="UDP") {
                usock=new UdpSocket(this);
                connect(usock,SIGNAL(RecvData(QHostAddress,unsigned short,QByteArray)),this,SLOT(UDPRecv(QHostAddress,unsigned short,QByteArray)));
                status=UDP;
                Log::log(csock,"requested UDP association");
            }
            qvm2.insert("status","ok");
            qvm2.insert("protocol",qvm["protocol"].toString());
            qvm2.insert("garbage",QString(randombytes_uniform(900),'f'));
            emit csock->SendData(QJsonDocument::fromVariant(qvm2).toJson());
            break;
        }
        case TCP:
            emit ssock->SendData(Data);
            break;
        case UDP: {
            QVariantMap qvm(QJsonDocument::fromJson(Data).toVariant().toMap());
            emit usock->SendData(qvm["host"].toString(),qvm["port"].toUInt(),QByteArray::fromBase64(qvm["data"].toByteArray()));
            Log::log(csock,"sent a UDP package to "+qvm["host"].toString()+':'+QString::number(qvm["port"].toUInt()));
        }
    }
Beispiel #24
0
bool CDVDSession::BeginSession()
{
    EndSession();

    if (m_hDrive == INVALID_HANDLE_VALUE) {
        return false;
    }

    DWORD BytesReturned;
    if (!DeviceIoControl(m_hDrive, IOCTL_DVD_START_SESSION, nullptr, 0, &m_session, sizeof(m_session), &BytesReturned, nullptr)) {
        m_session = DVD_END_ALL_SESSIONS;
        if (!DeviceIoControl(m_hDrive, IOCTL_DVD_END_SESSION, &m_session, sizeof(m_session), nullptr, 0, &BytesReturned, nullptr)
                || !DeviceIoControl(m_hDrive, IOCTL_DVD_START_SESSION, nullptr, 0, &m_session, sizeof(m_session), &BytesReturned, nullptr)) {
            Close();
            DWORD err = GetLastError();
            UNREFERENCED_PARAMETER(err);
            return false;
        }
    }

    return true;
}
Beispiel #25
0
BOOL CChatSelector::OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch (wParam) {
		case MP_DETAIL:{
			const CChatItem* ci = GetItemByIndex(m_iContextIndex);
			if (ci) {
				CClientDetailDialog dialog(ci->client);
				dialog.DoModal();
			}
			return TRUE;
		}
		case MP_ADDFRIEND:{
			const CChatItem* ci = GetItemByIndex(m_iContextIndex);
			if (ci) {
				CFriend* fr = theApp.friendlist->SearchFriend(ci->client->GetUserHash(), 0, 0);
				if (!fr)
					theApp.friendlist->AddFriend(ci->client);
			}
			return TRUE;
		}
		case MP_REMOVEFRIEND:{
			const CChatItem* ci = GetItemByIndex(m_iContextIndex);
			if (ci) {
				CFriend* fr = theApp.friendlist->SearchFriend(ci->client->GetUserHash(), 0, 0);
				if (fr)
					theApp.friendlist->RemoveFriend(fr);
			}
			return TRUE;
		}
		case MP_REMOVE:{
			const CChatItem* ci = GetItemByIndex(m_iContextIndex);
			if (ci)
				EndSession(ci->client);
			return TRUE;
		}
	}
	return CClosableTabCtrl::OnCommand(wParam, lParam);
}
Beispiel #26
0
CDVDSession::~CDVDSession()
{
    EndSession();
}
FAnalyticsProviderET::~FAnalyticsProviderET()
{
	UE_LOG(LogAnalytics, Verbose, TEXT("[%s] Destroying ET Analytics provider"), *APIKey);
	bInDestructor = true;
	EndSession();
}
Beispiel #28
0
Datei: xsm.c Projekt: aosm/X11
void
CloseDownClient(ClientRec *client)
{
    int index_deleted = 0;

    if (verbose) {
	printf ("ICE Connection closed, IceConn fd = %d\n",
		IceConnectionNumber (client->ice_conn));
	printf ("\n");
    }

    SmsCleanUp (client->smsConn);
    IceSetShutdownNegotiation (client->ice_conn, False);
    IceCloseConnection (client->ice_conn);

    client->ice_conn = NULL;
    client->smsConn = NULL;

    if (!shutdownInProgress && client_info_visible)
    {
	for (index_deleted = 0;
	    index_deleted < numClientListNames; index_deleted++)
	{
	    if (clientListRecs[index_deleted] == client)
		break;
	}
    }

    ListSearchAndFreeOne (RunningList, (char *) client);

    if (saveInProgress)
    {
	Status delStatus = ListSearchAndFreeOne (
	    WaitForSaveDoneList, (char *) client);

	if (delStatus)
	{
	    ListAddLast (FailedSaveList, (char *) client);
	    client->freeAfterBadSavePopup = True;
	}

	ListSearchAndFreeOne (WaitForInteractList, (char *) client);
	ListSearchAndFreeOne (WaitForPhase2List, (char *) client);

	if (delStatus && ListCount (WaitForSaveDoneList) == 0)
	{
	    if (ListCount (FailedSaveList) > 0 && !checkpoint_from_signal)
		PopupBadSave ();
	    else
		FinishUpSave ();
	}
	else if (ListCount (WaitForInteractList) > 0 &&
	    OkToEnterInteractPhase ())
	{
	    LetClientInteract (ListFirst (WaitForInteractList));
	}
	else if (!phase2InProgress &&
	    ListCount (WaitForPhase2List) > 0 && OkToEnterPhase2 ())
	{
	    StartPhase2 ();
	}
    }

    if (client->restartHint == SmRestartImmediately && !shutdownInProgress)
    {
	Clone (client, True /* use saved state */);

	ListAddLast (RestartImmedList, (char *) client);
    }
    else if (client->restartHint == SmRestartAnyway)
    {
	ListAddLast (RestartAnywayList, (char *) client);
    }
    else if (!client->freeAfterBadSavePopup)
    {
	FreeClient (client, True /* free props */);
    }

    if (shutdownInProgress)
    {
	if (ListCount (RunningList) == 0)
	    EndSession (0);
    }
    else if (client_info_visible)
    {
	UpdateClientList ();

	if (current_client_selected == index_deleted)
	{
	    if (current_client_selected == numClientListNames)
		current_client_selected--;

	    if (current_client_selected >= 0)
	    {
		XawListHighlight (clientListWidget, current_client_selected);
		ShowHint (clientListRecs[current_client_selected]);
		if (client_prop_visible)
		{
		    DisplayProps (clientListRecs[current_client_selected]);
		}
	    }
	}
	else
	{
	    if (index_deleted < current_client_selected)
		current_client_selected--;
	    XawListHighlight (clientListWidget, current_client_selected);
	}
    }
}
void CChatSelector::OnBnClickedCclose()
{
	EndSession();
}
void CriticalSection::Finalize() // must be called by the thread which wants to delete this object
{
	finalize = true;
	EndSession();
}