JXDockWidget::~JXDockWidget() { const JXDockManager::CloseDockMode mode = (JXGetDockManager())->GetCloseDockMode(); if (itsWindowList != NULL && mode == JXDockManager::kUndockWindows) { // can't call UndockAll() because that calls UpdateMinSize() const JSize count = itsWindowList->GetElementCount(); for (JIndex i=1; i<=count; i++) { JXWindow* w = itsWindowList->NthElement(i); StopListening(w); w->Undock(); } delete itsWindowList; } else if (itsWindowList != NULL) { assert( mode == JXDockManager::kCloseWindows ); const JSize count = itsWindowList->GetElementCount(); for (JIndex i=1; i<=count; i++) { JXWindow* w = itsWindowList->NthElement(i); StopListening(w); w->Close(); } delete itsWindowList; } }
CSensorListener::~CSensorListener() { StopListening(); delete iSensrvChannel; iSensrvChannel = NULL; }
void CBFileListTable::ReadSetup ( istream& input, const JFileVersion vers ) { RemoveAllFiles(); JSize fileCount; input >> fileCount; StopListening(GetFullNameDataList()); JString fileName; for (JIndex i=1; i<=fileCount; i++) { JFAID_t id; time_t t; input >> fileName >> id >> t; JIndex index; const JBoolean isNew = JXFileListTable::AddFile(fileName, &index); assert( isNew ); itsFileInfo->InsertElementAtIndex(index, FileInfo(id, t)); } ListenTo(GetFullNameDataList()); if (vers >= 80) { input >> itsLastUniqueID; }
void CMArray1DDir::CreateNodesFinished() { itsCurrentNode = NULL; StopListening(itsTree); itsStopButton->Hide(); }
ECode CGeckoNetworkManager::Stop() { mShouldBeListening = FALSE; if (mShouldNotify) { FAIL_RETURN(StopListening()); } return NOERROR; }
void JXFontCharSetMenu::BuildMenu ( const JCharacter* fontName, const JSize fontSize ) { RemoveAllItems(); JPtrArray<JString> charSetList(JPtrArrayT::kDeleteAll); if (!(GetFontManager())->GetFontCharSets(fontName, fontSize, &charSetList)) { itsCurrIndex = 0; itsCharSet.Clear(); StopListening(this); return; } const JSize count = charSetList.GetElementCount(); JString id; for (JIndex i=1; i<=count; i++) { const JString* charSet = charSetList.NthElement(i); id = *charSet + "::JX"; AppendItem(*charSet, kJTrue, kJTrue, NULL, NULL, id); } SetUpdateAction(kDisableNone); itsCurrIndex = 1; itsCharSet = *(charSetList.FirstElement()); StopListening(this); JString name, charSet; if (JFontManager::ExtractCharacterSet(fontName, &name, &charSet)) { SetCharSet(charSet); } else { SelectDefaultCharSet(); } ListenTo(this); }
/// <summary> /// Stop listening. /// </summary> void DgramListener::StopListening() { auto listener = _udpListener.lock(); // Will not throw if listener has destructed. if (listener) { listener->StopListening(); } }
ECode CGeckoNetworkManager::DisableNotifications() { mShouldNotify = FALSE; if (mShouldBeListening) { FAIL_RETURN(StopListening()); } return NOERROR; }
DgramListener::~DgramListener() { try { StopListening(); } catch (std::exception& ex) { cout << "Error closing Datagram listener: " << ex.what() << endl; } }
/* Destroys the LLCP socket. */ CLlcpServer::~CLlcpServer() { BEGIN StopListening(); iLlcpSocketArray.ResetAndDestroy();//this should destroy before iLlcp iLlcpSocketArray.Close(); iServiceName.Close(); delete iLlcp; iNfcServer.Close(); END }
void Test::Receive ( JBroadcaster* sender, const Message& message ) { std::cout << this << " received message of type " << message.GetType() << std::endl; StopListening(&t3); ListenTo(&t3); }
SyGApplication::~SyGApplication() { StopListening(itsShortcutList); // don't write empty taskbar file JPrefObject::WritePrefs(); delete itsWindowList; delete itsShortcutList; delete itsMountPointPrefs; delete itsMountPointList; SyGDeleteGlobals(); }
SVNListBase::~SVNListBase() { if (itsProcess != NULL) { StopListening(itsProcess); itsProcess->Kill(); } delete itsProcess; DeleteLinks(); JXDeleteObjectTask<JBroadcaster>::Delete(itsLineList); delete itsErrorList; delete itsSavedSelection; }
void JXImageSelection::SetData ( JXImage* image ) { if (itsImage != NULL) { StopListening(itsImage->GetXColormap()); delete itsImage; } itsImage = image; ListenTo(itsImage->GetXColormap()); }
JBoolean JXDockWidget::CloseAll() { if (itsWindowList != NULL) { JXDisplay* display = GetDisplay(); Display* xDisplay = display->GetXDisplay(); const JSize count = itsWindowList->GetElementCount(); for (JIndex i=count; i>=1; i--) { JXWindow* w = itsWindowList->NthElement(i); StopListening(w); Window xWindow = w->GetXWindow(); if (w->Close()) { if (JXDisplay::WindowExists(display, xDisplay, xWindow)) { w->Undock(); } else if ((JXGetApplication())->DisplayExists(xDisplay)) { itsTabGroup->DeleteTab(i); itsWindowList->RemoveElement(i); } else { return kJFalse; } } else { UpdateMinSize(); return kJFalse; } } delete itsWindowList; itsWindowList = NULL; UpdateMinSize(); } return kJTrue; }
void JXColorWheel::SetColor ( const JHSB& hsb ) { if (itsColor != hsb) { itsColor = hsb; StopListening(itsBrightnessSlider); itsBrightnessSlider->SetValue(itsColor.brightness); ListenTo(itsBrightnessSlider); Broadcast(ColorChanged()); Refresh(); } }
void CControlPanel::ListenToMessage(MessageT inMessage, void* ioParam) { LStaticText *theCaption; switch (inMessage) { case msg_BroadcasterDied: // maybe you should just StopListening(); break; case msg_RenderModeChanged: _renderingMode = *((UInt32*)ioParam); BroadcastMessage(msg_RenderModeChanged, ioParam); break; } UpdateValues(true); BroadcastMessage(msg_ControllerChanged ,nil); }
void GSNetworkListener::Slot5() { switch(myMenustatus) { case networklistener::CHOOSE: myNextState = new GSMenu(GameState::myWindow, GameState::mySettings, myResourcemanager); myResourcemanager = NULL; myNextStatus = NEXTSTATE; break; case networklistener::LISTENING: case networklistener::CONNECTED: StopListening(); Gui::SetMenupointText(2, "Start Listening"); Gui::SetMenupointText(4, "Main Menu"); Gui::ActivateMenupoint(0, true); Gui::ActivateMenupoint(1, true); myMenustatus = networklistener::CHOOSE; break; } }
void JXDockWidget::UndockAll() { if (itsWindowList != NULL) { const JSize count = itsWindowList->GetElementCount(); for (JIndex i=1; i<=count; i++) { itsTabGroup->DeleteTab(1); JXWindow* w = itsWindowList->NthElement(i); StopListening(w); w->Undock(); } itsWindowList->RemoveAll(); delete itsWindowList; itsWindowList = NULL; UpdateMinSize(); } }
// ------------------------------------------------------------------------- // // * ~TDCLBSDSocket( void ) // ------------------------------------------------------------------------- // TDCLBSDSocket::~TDCLBSDSocket( void ) { StopListening(); if (!mSocketsAreClosed) { if(mServerSocket >= 0) { (void) ::close( mServerSocket ); } if(mPublicPairMember >= 0) { (void) ::close( mPublicPairMember ); } if(mPrivatePairMember >= 0) { (void) ::close( mPrivatePairMember ); } } }
void CListenSocket::OnAccept(int nErrorCode) { // 0.42e if (!nErrorCode) { m_nPendingConnections++; if (m_nPendingConnections < 1) { wxFAIL; m_nPendingConnections = 1; } if (TooManySockets(true) && !theApp->serverconnect->IsConnecting()) { StopListening(); return; } else if (bListening == false) { // If the client is still at maxconnections, // this will allow it to go above it ... // But if you don't, you will get a lowID on all servers. ReStartListening(); } // Deal with the pending connections, there might be more than one, due to // the StopListening() call above. while (m_nPendingConnections) { m_nPendingConnections--; // Create a new socket to deal with the connection CClientTCPSocket* newclient = new CClientTCPSocket(); // Accept the connection and give it to the newly created socket if (!AcceptWith(*newclient, false)) { newclient->Safe_Delete(); } else { wxASSERT(theApp->IsRunning()); if (!newclient->InitNetworkData()) { // IP or port were not returned correctly // from the accepted address, or filtered. newclient->Safe_Delete(); } } } } }
void CBFnListDirector::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsActionsMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateActionsMenu(); } else if (sender == itsActionsMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleActionsMenu(selection->GetIndex()); } else if (sender == itsPrinter && message.Is(JPrinter::kPrintSetupFinished)) { const JPrinter::PrintSetupFinished* info = dynamic_cast<const JPrinter::PrintSetupFinished*>(&message); assert( info != NULL ); if (info->Successful()) { itsFnListWidget->Print(*itsPrinter); } StopListening(itsPrinter); } else { JXWindowDirector::Receive(sender, message); } }
void JXChooseMonoFont::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsFontMenu && message.Is(JXXFontMenu::kNameChanged)) { StopListening(itsSizeMenu); UpdateMenus(kJTrue); ListenTo(itsSizeMenu); Broadcast(FontChanged()); } else if (sender == itsSizeMenu && message.Is(JXFontSizeMenu::kSizeChanged)) { UpdateMenus(kJFalse); Broadcast(FontChanged()); } else { JXWidgetSet::Receive(sender, message); } }
void JXProgressDisplay::SetItems ( JXTextButton* cancelButton, JXStaticText* counter, JXProgressIndicator* indicator, JXTEBase* label ) { if (itsCancelButton != NULL) { StopListening(itsCancelButton); } itsCancelButton = cancelButton; itsCounter = counter; itsIndicator = indicator; itsLabel = label; if (itsCancelButton != NULL) { ListenTo(itsCancelButton); } }
GSNetworkListener::~GSNetworkListener() { StopListening(); delete myResourcemanager; }
SocketServer::~SocketServer() { m_inFinalRelease = true; StopListening(); }
int CloneMyself(void) { int child; char old_listen_arg[256]; char *arg_ptr = old_listen_arg; int i, j; int lastfdesc; char portnum[20]; assert(!drone_server); /* a drone shouldn't hit this */ if (!CloneSelf) return -1; #ifdef __UNIXOS2__ NoticeF("cloning of font server not supported under OS/2!\n"); return(-1); #endif old_listen_arg[0] = '\0'; lastfdesc = sysconf(_SC_OPEN_MAX) - 1; if ( (lastfdesc < 0) || (lastfdesc > MAXSOCKS)) { lastfdesc = MAXSOCKS; } NoticeF("attempting clone...\n"); chdir("/"); child = fork(); if (child == -1) { /* failed to fork */ ErrorF("clone failed to fork()\n"); return -1; } /* * Note: they still share the same process group, and killing the parent * will take out all the kids as well. this is considered a feature (at * least until i'm convinced otherwise) */ if (child == 0) { StopListening(); NoticeF("clone: child becoming drone\n"); drone_server = TRUE; return 1; } else { /* parent */ NoticeF("clone: parent revitalizing as %s\n", progname); CloseErrors(); /* XXX should we close stdio as well? */ for (i = 3; i < lastfdesc; i++) { for (j = 0; j < ListenTransCount; j++) if (ListenTransFds[j] == i) break; if (j >= ListenTransCount) (void) close(i); } for (i = 0; i < ListenTransCount; i++) { int trans_id, fd; char *port; if (!_FontTransGetReopenInfo (ListenTransConns[i], &trans_id, &fd, &port)) continue; sprintf (arg_ptr, "%d/%d/%s", trans_id, fd, port); arg_ptr += strlen (arg_ptr); free (port); if (i < ListenTransCount - 1) { strcat (arg_ptr, ","); arg_ptr++; } } sprintf (portnum, "%d", ListenPort); if (*old_listen_arg != '\0') execlp(progname, progname, "-ls", old_listen_arg, "-cf", configfilename, "-port", portnum, (void *)NULL); InitErrors(); /* reopen errors, since we don't want to lose * this */ Error("clone failed"); FatalError("failed to clone self\n"); } /* NOTREACHED */ return 0; }
void GPMProcessTreeList::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsList && message.Is(GPMProcessList::kPrepareForUpdate)) { if (itsSelectedEntry != NULL) { StopListening(itsSelectedEntry); itsSelectedEntry = NULL; } if (GetSelectedProcess(&itsSelectedEntry)) { ClearWhenGoingAway(itsSelectedEntry, &itsSelectedEntry); } } else if (sender == itsList && message.Is(GPMProcessList::kListChanged)) { JTableSelection& s = GetTableSelection(); s.ClearSelection(); JIndex index; if (itsSelectedEntry != NULL && GetTreeList()->FindNode(itsSelectedEntry, &index)) { s.SelectRow(index); StopListening(itsSelectedEntry); itsSelectedEntry = NULL; } Refresh(); } else if (sender == itsContextMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateContextMenu(); } else if (sender == itsContextMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleContextMenu(selection->GetIndex()); } else { if (sender == &(GetTableSelection()) && message.Is(JTableData::kRectChanged)) { const GPMProcessEntry* entry; if (IsVisible() && GetSelectedProcess(&entry)) { itsFullCmdDisplay->SetText(entry->GetFullCommand()); } } JXNamedTreeListWidget::Receive(sender, message); } }
JBoolean CBCommand::StartProcess() { // check if we are finished while (!itsCmdList->IsEmpty() && (itsCmdList->GetElement(1)).IsEndOfSequence()) { CmdInfo info = itsCmdList->GetElement(1); info.Free(kJTrue); itsCmdList->RemoveElement(1); } if (itsCmdList->IsEmpty()) { if (itsBeepFlag && itsParent == NULL) { ((JXGetApplication())->GetCurrentDisplay())->Beep(); } DeleteThis(); return kJFalse; } // check if we can use the window itsInQueueFlag = kJFalse; if (itsOutputDoc != NULL && itsOutputDoc->ProcessRunning()) { itsInQueueFlag = kJTrue; ListenTo(itsOutputDoc); return kJTrue; // wait for message from itsOutputDoc } // check if need to run a subroutine CmdInfo info = itsCmdList->GetElement(1); if (info.cmdObj != NULL) { StopListening(itsOutputDoc); // wait for CBCommand to notify us const JBoolean result = (info.cmdObj)->Start(*(info.cmdInfo)); info.Free(kJFalse); itsCmdList->RemoveElement(1); return result; } // start process assert( info.cmd != NULL ); JShouldIncludeCWDOnPath(kJTrue); JProcess* p; int toFD, fromFD; JError execErr = JNoError(); if (itsOutputDoc != NULL) { execErr = JProcess::Create(&p, itsCmdPath, *(info.cmd), kJCreatePipe, &toFD, kJCreatePipe, &fromFD, kJAttachToFromFD, NULL); } else { JSimpleProcess* p1; execErr = JSimpleProcess::Create(&p1, itsCmdPath, *(info.cmd), kJTrue); p = p1; } JShouldIncludeCWDOnPath(kJFalse); if (!execErr.OK()) { execErr.ReportIfError(); DeleteThis(); return kJFalse; } if (itsOutputDoc != NULL) { const JSize count = info.cmd->GetElementCount(); JString cmd; for (JIndex i=1; i<=count; i++) { cmd += JPrepArgForExec(*info.cmd->NthElement(i)); cmd += " "; } itsOutputDoc->SetConnection(p, fromFD, toFD, itsWindowTitle, itsDontCloseMsg, itsCmdPath, cmd, kJTrue); // We can't do this in Start() because we might be waiting for // itsMakeDependCmd. We must not listen to both at the same time. ListenTo(itsOutputDoc); } else { ListenTo(p); JThisProcess::Ignore(p); } info.Free(kJTrue); itsCmdList->RemoveElement(1); return kJTrue; }
void CListenSocket::OnAccept(int nErrorCode) { if (!nErrorCode) { m_nPendingConnections++; if (m_nPendingConnections < 1){ ASSERT(0); m_nPendingConnections = 1; } if (TooManySockets(true) && !CGlobalVariable::serverconnect->IsConnecting()){ StopListening(); return; } else if (!bListening) ReStartListening(); //If the client is still at maxconnections, this will allow it to go above it.. But if you don't, you will get a lowID on all servers. uint32 nFataErrors = 0; while (m_nPendingConnections > 0) { m_nPendingConnections--; CClientReqSocket* newclient; SOCKADDR_IN SockAddr = {0}; int iSockAddrLen = sizeof SockAddr; if (thePrefs.GetConditionalTCPAccept() && !thePrefs.GetProxySettings().UseProxy) { _iAcceptConnectionCondRejected = 0; SOCKET sNew = WSAAccept(m_SocketData.hSocket, (SOCKADDR*)&SockAddr, &iSockAddrLen, AcceptConnectionCond, 0); if (sNew == INVALID_SOCKET){ DWORD nError = GetLastError(); if (nError == WSAEWOULDBLOCK){ DebugLogError(LOG_STATUSBAR, _T("%hs: Backlogcounter says %u connections waiting, Accept() says WSAEWOULDBLOCK - setting counter to zero!"), __FUNCTION__, m_nPendingConnections); m_nPendingConnections = 0; break; } else{ if (nError != WSAECONNREFUSED || _iAcceptConnectionCondRejected == 0){ DebugLogError(LOG_STATUSBAR, _T("%hs: Backlogcounter says %u connections waiting, Accept() says %s - setting counter to zero!"), __FUNCTION__, m_nPendingConnections, GetErrorMessage(nError, 1)); nFataErrors++; } else if (_iAcceptConnectionCondRejected == 1) theStats.filteredclients++; } if (nFataErrors > 10){ // the question is what todo on a error. We cant just ignore it because then the backlog will fill up // and lock everything. We can also just endlos try to repeat it because this will lock up eMule // this should basically never happen anyway // however if we are in such a position, try to reinitalize the socket. DebugLogError(LOG_STATUSBAR, _T("%hs: Accept() Error Loop, recreating socket"), __FUNCTION__); Close(); StartListening(); m_nPendingConnections = 0; break; } continue; } newclient = new CClientReqSocket; VERIFY( newclient->InitAsyncSocketExInstance() ); newclient->m_SocketData.hSocket = sNew; newclient->AttachHandle(sNew); AddConnection(); } else { newclient = new CClientReqSocket; if (!Accept(*newclient, (SOCKADDR*)&SockAddr, &iSockAddrLen)){ newclient->Safe_Delete(); DWORD nError = GetLastError(); if (nError == WSAEWOULDBLOCK){ DebugLogError(LOG_STATUSBAR, _T("%hs: Backlogcounter says %u connections waiting, Accept() says WSAEWOULDBLOCK - setting counter to zero!"), __FUNCTION__, m_nPendingConnections); m_nPendingConnections = 0; break; } else{ DebugLogError(LOG_STATUSBAR, _T("%hs: Backlogcounter says %u connections waiting, Accept() says %s - setting counter to zero!"), __FUNCTION__, m_nPendingConnections, GetErrorMessage(nError, 1)); nFataErrors++; } if (nFataErrors > 10){ // the question is what todo on a error. We cant just ignore it because then the backlog will fill up // and lock everything. We can also just endlos try to repeat it because this will lock up eMule // this should basically never happen anyway // however if we are in such a position, try to reinitalize the socket. DebugLogError(LOG_STATUSBAR, _T("%hs: Accept() Error Loop, recreating socket"), __FUNCTION__); Close(); StartListening(); m_nPendingConnections = 0; break; } continue; } AddConnection(); if (SockAddr.sin_addr.S_un.S_addr == 0) // for safety.. { iSockAddrLen = sizeof SockAddr; newclient->GetPeerName((SOCKADDR*)&SockAddr, &iSockAddrLen); DebugLogWarning(_T("SockAddr.sin_addr.S_un.S_addr == 0; GetPeerName returned %s"), ipstr(SockAddr.sin_addr.S_un.S_addr)); } ASSERT( SockAddr.sin_addr.S_un.S_addr != 0 && SockAddr.sin_addr.S_un.S_addr != INADDR_NONE ); if (CGlobalVariable::ipfilter->IsFiltered(SockAddr.sin_addr.S_un.S_addr)){ if (thePrefs.GetLogFilteredIPs()) AddDebugLogLine(false, _T("Rejecting connection attempt (IP=%s) - IP filter (%s)"), ipstr(SockAddr.sin_addr.S_un.S_addr), CGlobalVariable::ipfilter->GetLastHit()); newclient->Safe_Delete(); theStats.filteredclients++; continue; } if (CGlobalVariable::clientlist->IsBannedClient(SockAddr.sin_addr.S_un.S_addr)){ if (thePrefs.GetLogBannedClients()){ CUpDownClient* pClient = CGlobalVariable::clientlist->FindClientByIP(SockAddr.sin_addr.S_un.S_addr); AddDebugLogLine(false, _T("Rejecting connection attempt of banned client %s %s"), ipstr(SockAddr.sin_addr.S_un.S_addr), pClient->DbgGetClientInfo()); } newclient->Safe_Delete(); continue; } } newclient->AsyncSelect(FD_WRITE | FD_READ | FD_CLOSE); } ASSERT( m_nPendingConnections >= 0 ); } }