void close() override { invokeEvent(EventType::CLOSE_BEGIN, "", -1, -1); m_file.close(); invokeEvent(EventType::CLOSE_FINISHED, "", -1, -1); }
bool open(const Path& path, Mode mode) override { invokeEvent(EventType::OPEN_BEGIN, path.c_str(), -1, mode); bool ret = m_file.open(path, mode); invokeEvent(EventType::OPEN_FINISHED, path.c_str(), ret ? 1 : 0, mode); return ret; }
bool write(const void* buffer, size_t size) override { invokeEvent(EventType::WRITE_BEGIN, "", -1, (int32)size); bool ret = m_file.write(buffer, size); invokeEvent(EventType::WRITE_FINISHED, "", ret ? 1 : 0, (int32)size); return ret; }
bool read(void* buffer, size_t size) override { invokeEvent(EventType::READ_BEGIN, "", -1, (int32)size); bool ret = m_file.read(buffer, size); invokeEvent(EventType::READ_FINISHED, "", ret ? 1 : 0, (int32)size); return ret; }
size_t seek(SeekMode base, size_t pos) override { invokeEvent(EventType::SEEK_BEGIN, "", (int32)pos, base); size_t ret = m_file.seek(base, pos); invokeEvent(EventType::SEEK_FINISHED, "", (int32)ret, base); return ret; }
size_t size() override { invokeEvent(EventType::SIZE_BEGIN, "", -1, -1); size_t ret = m_file.size(); invokeEvent(EventType::SIZE_FINISHED, "", (int32)ret, -1); return ret; }
size_t pos() override { invokeEvent(EventType::POS_BEGIN, "", -1, -1); size_t ret = m_file.pos(); invokeEvent(EventType::POS_FINISHED, "", (int32)ret, -1); return ret; }
virtual bool open(const char* path, Mode mode) override { invokeEvent(EventType::OPEN_BEGIN, path, -1, mode); bool ret = m_file.open(path, mode); invokeEvent(EventType::OPEN_FINISHED, path, ret ? 1 : 0, mode); return ret; }
void cTranscript::startAdvTranscript () { QString af; if (advrunning) stopAdvTranscript (); cTelnet *telnet = dynamic_cast<cTelnet *>(object ("telnet")); if (!(telnet->isConnected())) //no transcript if we aren't connected return; if(advfname.isEmpty()) return; // no transcript if advanced filename failed errno = 0; transtimer = new QTimer(); connect (transtimer, SIGNAL (timeout ()), this, SLOT (timeout ())); cProfileSettings *sett = settings (); af = sett ? sett->getString ("transcript-directory") : QDir::homePath(); af += advfname; advfile = fopen (af.toLatin1(), "a"); if (advfile == NULL) { KMessageBox::detailedSorry (cActionManager::self()->mainWidget(), i18n ("Advanced transcript file could not be opened."), strerror (errno)); errno = 0; invokeEvent ("message", sess(), i18n ("Advanced session transcript could not be started.")); } else { advrunning = true; cOutput *output = dynamic_cast<cOutput *>(object ("output")); fputs ("\n\n", advfile); if (advtype == TRANSCRIPT_HTML) { //TODO: what if we're adding to an existing HTML transcript? fputs ("<html>\n", advfile); fputs ("<meta name=\"Generator\" content=\"KMuddy\">\n", advfile); fputs ("<body bgcolor=", advfile); fputs (output->defaultBkColor().name().toLatin1(), advfile); fputs (">\n", advfile); } QString s = i18n ("Advanced session transcript has just started."); fputs (s.toLatin1(), advfile); if (advtype == TRANSCRIPT_HTML) fputs ("<br><pre>", advfile); //pre-formatted text starting... fputs ("\n\n", advfile); invokeEvent ("message", sess(), i18n ("Advanced session transcript has been started.")); if (rotatedaily) { invokeEvent ("message", sess(), i18n ("Session transcript will be rotated at midnight.")); transtimer->start (60000); } } }
void cTranscript::stopAdvTranscript () { if (!advrunning) return; fputs ("\n\n", advfile); if (type == TRANSCRIPT_ANSI) //ANSI transcript { //set output color to default (usually gray on black) char defcolor[5]; defcolor[0] = 27; defcolor[1] = '['; defcolor[2] = '0'; defcolor[3] = 'm'; defcolor[4] = 0; fputs (defcolor, advfile); } if (type == TRANSCRIPT_HTML) //HTML transcript { //closing HTML tags fputs ("</pre></body></html>\n", advfile); } advrunning = false; fclose (advfile); advfile = 0; if (transtimer->isActive ()) { transtimer->stop (); delete transtimer; } invokeEvent ("message", sess(), i18n ("Advanced session transcript has been stopped.")); }
void cTranscript::stopTranscript () { if (!running) return; fputs ("\n\n", file); if (type == TRANSCRIPT_ANSI) //ANSI transcript { //set output color to default (usually gray on black) char defcolor[5]; defcolor[0] = 27; defcolor[1] = '['; defcolor[2] = '0'; defcolor[3] = 'm'; defcolor[4] = 0; fputs (defcolor, file); } if (type == TRANSCRIPT_HTML) //HTML transcript { //closing HTML tags fputs ("</pre></body></html>\n", file); } running = false; fclose (file); file = 0; invokeEvent ("message", sess(), i18n ("Session transcript has been stopped.")); }
void CanvasProcessor::propagateEvent(Event* event, Outport* source) { if (event->hasVisitedProcessor(this)) return; event->markAsVisited(this); invokeEvent(event); if (event->hasBeenUsed()) return; if (event->hash() == ResizeEvent::chash()) { auto resizeEvent = static_cast<ResizeEvent*>(event); // Avoid continues evaluation when port dimensions changes NetworkLock lock(this); dimensions_.set(resizeEvent->size()); if (enableCustomInputDimensions_) { sizeChanged(); } else { inport_.propagateEvent(resizeEvent, nullptr); // Make sure this processor is invalidated. invalidate(InvalidationLevel::InvalidOutput); } } else { bool used = event->hasBeenUsed(); for (auto inport : getInports()) { if (event->shouldPropagateTo(inport, this, source)) { inport->propagateEvent(event); used |= event->hasBeenUsed(); event->markAsUnused(); } } if (used) event->markAsUsed(); } }
// 接続失敗時 void CSCConnection::onConnectionFailed() { CAuthEvent* event = new CAuthEvent(); event->setAuthResult(false); event->SetEventType(myEVT_THREAD_GET_PING); // イベントの種類をセット invokeEvent(event); }
void cTranscript::startTranscript () { //we'll have multiple <html></html> sections in a transcript file if we continue an existing //one, but every browser that I've tested can handle it correctly :D if (running) stopTranscript (); cTelnet *telnet = dynamic_cast<cTelnet *>(object ("telnet")); if (!(telnet->isConnected())) //no transcript if we aren't connected return; errno = 0; file = fopen (fname.toLatin1(), overwrite ? "w" : "a"); if (file == NULL) { KMessageBox::detailedSorry (cActionManager::self()->mainWidget(), i18n ("Transcript file could not be opened."), strerror (errno)); errno = 0; invokeEvent ("message", sess(), i18n ("Session transcript could not be started.")); } else { running = true; cOutput *output = dynamic_cast<cOutput *>(object ("output")); fputs ("\n\n", file); if (type == TRANSCRIPT_HTML) { //TODO: what if we're adding to an existing HTML transcript? fputs ("<html>\n", file); fputs ("<meta name=\"Generator\" content=\"KMuddy\">\n", file); fputs ("<body bgcolor=", file); fputs (output->defaultBkColor().name().toLatin1(), file); fputs (">\n", file); } QString s = i18n ("Session transcript has just started."); fputs (s.toLatin1(), file); if (type == TRANSCRIPT_HTML) fputs ("<br><pre>", file); //pre-formatted text starting... fputs ("\n\n", file); //add buffer dump if requested if (includedump) output->console()->dumpBuffer (false, file, type); invokeEvent ("message", sess(), i18n ("Session transcript has been started.")); } }
// メッセージ取得 void CSCConnection::onMessageReceived(CMessageData* message) { CSCMessageData* scMessage = dynamic_cast<CSCMessageData*>(message); CSCEventFactory factory; CConnectionEventBase* event = factory.Create(*scMessage); if (event != NULL){ invokeEvent(event); } }
void Processor::propagateEvent(Event* event) { invokeEvent(event); if (event->hasBeenUsed()) return; for (auto inport : getInports()) { inport->propagateEvent(event); if (event->hasBeenUsed()) return; } }
unsigned int cCmdParser::repeater (QString &command) { bool multi = false; if ((multistr.length() > 0) && (command.startsWith (multistr))) multi = true; if (multi) //chance is that there is some repeater { QString cmd = command; cmd.remove (0, multistr.length()); cmd = cmd.trimmed (); QString rep = cmd.section (' ', 0, 0); //first section //if rep is a number, then this is a multi-command bool ok; unsigned int repc = rep.toUInt (&ok); if (ok) //GREAT!!! This really is a repeater command!!! { command = command.section (' ', 1); //everything except the 1st section //limit repeat count if needed cProfileSettings *sett = settings (); bool limitRepeats = ((sett == 0) ? true : sett->getBool ("limit-repeater")); if ((repc > 100) && limitRepeats) { invokeEvent ("message", sess(), i18n ("Sorry, count is limited to 100.\n")); if (sett) invokeEvent ("message", sess(), i18n ("You can disable this limit in Profile / MUD Preferences.")); //return 0 - nothing will be sent... return 0; } return repc; } else //no repeater here... return 1; } else //no repeater -> count is 1 return 1; }
void ImageLayoutGL::propagateEvent(Event* event) { invokeEvent(event); std::unique_ptr<Event> newEvent(viewManager_.registerEvent(event)); int activeView = viewManager_.getActiveView(); auto data = multiinport_.getConnectedOutports(); if (newEvent && activeView >= 0 && activeView < static_cast<long>(data.size()) ) { multiinport_.propagateEvent(newEvent.get(), data[activeView]); if (newEvent->hasBeenUsed()) event->markAsUsed(); } }
// 切断時 void CSCConnection::onDisconnected() { CDisconnectEvent* event = new CDisconnectEvent(); event->SetEventType(myEVT_THREAD_DISCONNECT); // イベントの種類をセット invokeEvent(event); }