//------------------------------------------------------------------------------------- void TelnetHandler::onProfileEnd(const std::string& datas) { sendEnter(); pEndPoint()->send(datas.c_str(), datas.size()); setReadWrite(); sendEnter(); sendNewLine(); pProfileHandler_ = NULL; }
void ATerminal :: help(AStream *stream) { trmDisplay.help(stream); sendEnter(stream); trmPower.help(stream); sendEnter(stream); trmMotors.help(stream); sendEnter(stream); trmTime.help(stream); sendEnter(stream); trmPrint.help(stream); sendEnter(stream); stream->printPgm(TEXT("exit - disconnect terminal")); }
//------------------------------------------------------------------------------------- void TelnetHandler::processPythonCommand(std::string command) { if(pTelnetServer_->pScript() == NULL || command.size() == 0) return; command += "\n"; PyObject* pycmd = PyUnicode_DecodeUTF8(command.data(), command.size(), NULL); if(pycmd == NULL) { SCRIPT_ERROR_CHECK(); return; } DEBUG_MSG(boost::format("TelnetHandler::processPythonCommand: size(%1%), command=%2%.\n") % command.size() % command); std::string retbuf = ""; PyObject* pycmd1 = PyUnicode_AsEncodedString(pycmd, "utf-8", NULL); pTelnetServer_->pScript()->run_simpleString(PyBytes_AsString(pycmd1), &retbuf); if(retbuf.size() > 0) { // 将结果返回给客户端 Mercury::Bundle bundle; bundle << retbuf; bundle.send(*pEndPoint_); sendEnter(); } Py_DECREF(pycmd); Py_DECREF(pycmd1); }
/* Track the current mouse position. */ static enum XdndState dndOutMotion(enum XdndState state, XMotionEvent *evt) { Window currentWindow= None; int versionReturn= 0; if ((XdndStateOutTracking != state) && (XdndStateOutAccepted != state)) return state; currentWindow= dndAwareWindow(evt->root, evt->root, &versionReturn); if (DndWindow == currentWindow) /* Cursor is on myself */ { xdndOutTarget= None; return XdndStateOutTracking; } updateCursor(XdndStateOutAccepted == state); if ((XdndVersion > versionReturn) /* Target's version is too low. */ || (None == currentWindow)) /* I can't find XdndAware window. */ { xdndOutTarget= None; return XdndStateOutTracking; } fdebugf((stderr, "Receive MotionNotify (output) root: 0x%lx awareWindow: 0x%lx\n", evt->root, currentWindow)); if (currentWindow != xdndOutTarget) { sendLeave(xdndOutTarget, DndWindow); sendEnter(currentWindow, DndWindow); } sendPosition(currentWindow, DndWindow, evt->x_root, evt->y_root, evt->time); xdndOutTarget= currentWindow; return state; }
void KeyboardInterface::Private::focusChildSurface(const QPointer<SurfaceInterface> &childSurface, quint32 serial) { if (focusedChildSurface == childSurface) { return; } sendLeave(focusedChildSurface.data(), serial); focusedChildSurface = childSurface; sendEnter(focusedChildSurface.data(), serial); }
void QWaylandKeyboardPrivate::checkFocusResource(Resource *keyboardResource) { if (!keyboardResource || !focus) return; // this is already the current resource, do no send enter twice if (focusResource == keyboardResource) return; // check if new wl_keyboard resource is from the client owning the focus surface if (focus->resource()->client == keyboardResource->client()) { sendEnter(focus, keyboardResource); focusResource = keyboardResource; } }
//------------------------------------------------------------------------------------- void TelnetHandler::processPythonCommand(std::string command) { if(pTelnetServer_->pScript() == NULL || command.size() == 0) return; command += "\n"; PyObject* pycmd = PyUnicode_DecodeUTF8(command.data(), command.size(), NULL); if(pycmd == NULL) { SCRIPT_ERROR_CHECK(); return; } DEBUG_MSG(fmt::format("TelnetHandler::processPythonCommand: size({}), command={}.\n", command.size(), command)); std::string retbuf = ""; PyObject* pycmd1 = PyUnicode_AsEncodedString(pycmd, "utf-8", NULL); pTelnetServer_->pScript()->run_simpleString(PyBytes_AsString(pycmd1), &retbuf); // 把返回值中的'\n'替換成'\r\n',以解决在vt100终端中显示不正确的问题 std::string::size_type pos = 0; while ((pos = retbuf.find('\n', pos)) != std::string::npos) { if (retbuf[pos - 1] != '\r') { retbuf.insert(pos, "\r"); pos++; } pos++; } if(retbuf.size() > 0) { // 将结果返回给客户端 Network::Bundle* pBundle = Network::Bundle::createPoolObject(); (*pBundle) << retbuf; pEndPoint_->send(pBundle); Network::Bundle::reclaimPoolObject(pBundle); sendEnter(); } Py_DECREF(pycmd); Py_DECREF(pycmd1); }
u8 PWS_SendData (u8 Slot_u8, u8 Kind_u8) { u8 SendString_au8[40]; u32 Ret_u32; // LED_GreenOn (); switch (Kind_u8) { case PWS_SEND_PASSWORD: Ret_u32 = PWS_GetSlotPassword (Slot_u8, SendString_au8); if (FALSE == Ret_u32) { return (FALSE); } sendString ((char *) SendString_au8, strlen ((char *) SendString_au8)); break; case PWS_SEND_LOGINNAME: Ret_u32 = PWS_GetSlotLoginName (Slot_u8, SendString_au8); if (FALSE == Ret_u32) { return (FALSE); } sendString ((char *) SendString_au8, strlen ((char *) SendString_au8)); break; case PWS_SEND_TAB: sendTab (); break; case PWS_SEND_CR: sendEnter (); break; } // LED_GreenOff (); return (TRUE); }
void QWaylandKeyboardPrivate::focused(QWaylandSurface *surface) { if (surface && surface->isCursorSurface()) surface = Q_NULLPTR; if (focus != surface) { if (focusResource) { uint32_t serial = compositor()->nextSerial(); send_leave(focusResource->handle, serial, focus->resource()); } focusDestroyListener.reset(); if (surface) focusDestroyListener.listenForDestruction(surface->resource()); } Resource *resource = surface ? resourceMap().value(surface->waylandClient()) : 0; if (resource && (focus != surface || focusResource != resource)) sendEnter(surface, resource); focusResource = resource; focus = surface; Q_EMIT q_func()->focusChanged(focus); }
//------------------------------------------------------------------------------------- bool TelnetHandler::processCommand() { if(command_.size() == 0) { sendNewLine(); return true; } if(state_ == TELNET_STATE_PASSWD) { if(command_ == pTelnetServer_->passwd()) { state_ = (TELNET_STATE)pTelnetServer_->deflayer(); std::string s = getWelcome(); pEndPoint_->send(s.c_str(), s.size()); command_ = ""; sendEnter(); sendNewLine(); return true; } else { command_ = ""; sendNewLine(); return true; } } bool logcmd = true; //for(int i=0; i<(int)historyCommand_.size(); ++i) { //if(historyCommand_[i] == command_) //{ // logcmd = false; // break; //} } if(logcmd) { historyCommand_.push_back(command_); historyCommandCheck(); historyCommandIndex_ = historyCommand_.size() - 1; } std::string cmd = command_; command_ = ""; if(cmd == ":python") { if(pTelnetServer_->pScript() == NULL) return true; state_ = TELNET_STATE_PYTHON; sendNewLine(); return true; } else if(cmd == ":help") { std::string str = help(); pEndPoint_->send(str.c_str(), str.size()); sendNewLine(); return true; } else if(cmd == ":root") { sendNewLine(); state_ = TELNET_STATE_ROOT; return true; } else if(cmd == ":quit") { state_ = TELNET_STATE_QUIT; pTelnetServer_->closeHandler((*pEndPoint_), this); return false; } else if(cmd.find(":cprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":cprofile"), strlen(":cprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetCProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } else if(cmd.find(":pyprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":pyprofile"), strlen(":pyprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetPyProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } else if(cmd.find(":eventprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":eventprofile"), strlen(":eventprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetEventProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } else if(cmd.find(":networkprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":networkprofile"), strlen(":networkprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetNetworkProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } if(state_ == TELNET_STATE_PYTHON) { processPythonCommand(cmd); } sendNewLine(); return true; }