// start = 1: speaking status changed to start, start = 0: status changed to stop void cSemaineUserinfoSender::sendSpeakingStatus( cComponentMessage *_msg, int start ) { const char *strtmp = "stop"; if (start) strtmp = "start"; std::string statusStr(strtmp); char strtmp2[50]; sprintf(strtmp2,"%ld",smileTimeToSemaineTime(_msg->userTime1)); std::string startTm(strtmp2); // Create and fill a simple EMMA EmotionML document XERCESC_NS::DOMDocument * document = XMLTool::newDocument(EMMA::E_EMMA, EMMA::namespaceURI, EMMA::version); XMLTool::setPrefix(document->getDocumentElement(), "emma"); XERCESC_NS::DOMElement * interpretation = XMLTool::appendChildElement(document->getDocumentElement(), EMMA::E_INTERPRETATION); XMLTool::setAttribute(interpretation, EMMA::A_OFFSET_TO_START, startTm); XMLTool::setAttribute(interpretation, EMMA::A_DURATION, "0"); XMLTool::setPrefix(interpretation, "emma"); XERCESC_NS::DOMElement * speaking = XMLTool::appendChildElement(interpretation, SemaineML::E_SPEAKING, SemaineML::namespaceURI); XMLTool::setAttribute(speaking, SemaineML::A_STATUS_CHANGE, strtmp); XMLTool::setPrefix(speaking, "semaine"); // Now send it sendDocument(document); }
void update_rx_locked() { if (m_device) { tcat::dice::EX_STATUS rx_status = m_device->rx_locked(); setStatus("device rx lock changed:", false); setStatus("arx4 arx3 arx2 arx1 tdif adat aes4 aes3 aes2 aes1", false); String statusStr(String::empty); for (int i=9; i>=0; i--) { if (rx_status & (1<<i)) statusStr << " L "; else statusStr << " U "; } setStatus(statusStr, true); triggerAsyncUpdate(); } }
/** serializes the HTTP response status line plus headers into a byte-stream. * * This method is invoked right before the response content is written or the * response is flushed at all. * * It first sets the status code (if not done yet), invoked post_process callback, * performs connection-level response header modifications and then * builds the response chunk for status line and headers. * * Post-modification done <b>after</b> the post_process hook has been invoked: * <ol> * <li>set status code to 200 (Ok) if not set yet.</li> * <li>set Content-Type header to a default if not set yet.</li> * <li>set Connection header to keep-alive or close (computed value)</li> * <li>append Transfer-Encoding chunked if no Content-Length header is set.</li> * <li>optionally enable TCP_CORK if this is no keep-alive connection and the administrator allows it.</li> * </ol> * * \note this does not serialize the message body. */ Source* HttpRequest::serialize() { Buffer buffers; if (expectingContinue) status = HttpStatus::ExpectationFailed; else if (status == static_cast<HttpStatus>(0)) status = HttpStatus::Ok; if (!responseHeaders.contains("Content-Type")) { responseHeaders.push_back("Content-Type", "text/plain"); //!< \todo pass "default" content-type instead! } if (connection.worker().server().advertise() && !connection.worker().server().tag().empty()) { if (!responseHeaders.contains("Server")) { responseHeaders.push_back("Server", connection.worker().server().tag()); } else { responseHeaders.push_back("Via", connection.worker().server().tag()); } } // post-response hook connection.worker().server().onPostProcess(this); // setup (connection-level) response transfer if (supportsProtocol(1, 1) && !responseHeaders.contains("Content-Length") && !responseHeaders.contains("Transfer-Encoding") && !isResponseContentForbidden()) { responseHeaders.push_back("Transfer-Encoding", "chunked"); outputFilters.push_back(std::make_shared<ChunkedEncoder>()); } bool keepalive = connection.shouldKeepAlive(); if (!connection.worker().server().maxKeepAlive()) keepalive = false; // remaining request count, that is allowed on a persistent connection std::size_t rlim = connection.worker().server().maxKeepAliveRequests(); if (rlim) { rlim = connection.requestCount_ <= rlim ? rlim - connection.requestCount_ + 1 : 0; if (rlim == 0) // disable keep-alive, if max request count has been reached keepalive = false; } // only set Connection-response-header if found as request-header, too if (!requestHeader("Connection").empty() || keepalive != connection.shouldKeepAlive()) { if (keepalive) { responseHeaders.overwrite("Connection", "keep-alive"); if (rlim) { // sent keep-alive timeout and remaining request count char buf[80]; snprintf(buf, sizeof(buf), "timeout=%ld, max=%ld", static_cast<time_t>(connection.worker().server().maxKeepAlive().value()), rlim); responseHeaders.overwrite("Keep-Alive", buf); } else { // sent keep-alive timeout only (infinite request count) char buf[80]; snprintf(buf, sizeof(buf), "timeout=%ld", static_cast<time_t>(connection.worker().server().maxKeepAlive().value())); responseHeaders.overwrite("Keep-Alive", buf); } } else responseHeaders.overwrite("Connection", "close"); } connection.setShouldKeepAlive(keepalive); if (!connection.worker().server().tcpCork()) connection.socket()->setTcpCork(true); if (supportsProtocol(1, 1)) buffers.push_back("HTTP/1.1 "); else if (supportsProtocol(1, 0)) buffers.push_back("HTTP/1.0 "); else buffers.push_back("HTTP/0.9 "); buffers.push_back(statusCodes_[static_cast<int>(status)]); buffers.push_back(' '); buffers.push_back(statusStr(status)); buffers.push_back("\r\n"); for (auto& i: responseHeaders) { buffers.push_back(i.name.data(), i.name.size()); buffers.push_back(": "); buffers.push_back(i.value.data(), i.value.size()); buffers.push_back("\r\n"); }; buffers.push_back("\r\n"); return new BufferSource(std::move(buffers)); }
void QTorrentItemDelegat::drawTorrent(QPainter* painter, const QStyleOptionViewItem& option, const Torrent& tor, const QModelIndex& index) const { QStyleOptionViewItemV4 opt = option; initStyleOption(&opt, index); QStyle* style; if(opt.widget != NULL) { style = opt.widget->style(); } else { style = QApplication::style(); } const int iconSize(style->pixelMetric(QStyle::PM_LargeIconSize)); QFont nameFont(option.font); nameFont.setWeight(QFont::Bold); const QFontMetrics nameFM(nameFont); const QIcon mimeIcon(tor.GetMimeTypeIcon()); QString nameStr(tor.GetName()); QSize nameSize(nameFM.size(0, nameStr)); QFont statusFont(option.font); statusFont.setPointSize(int (option.font.pointSize() * 0.9)); const QFontMetrics statusFM(statusFont); QString statusStr(GetStatusString(tor)); int statusWidth = statusFM.width(statusStr); QFont progressFont(statusFont); const QFontMetrics progressFM(progressFont); QString progressStr(GetProgressString(tor)); bool isPaused(tor.isPaused()); painter->save(); painter->setRenderHint(QPainter::Antialiasing); style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget); /* if (option.state & QStyle::State_Selected) { QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Active : QPalette::Disabled; if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) cg = QPalette::Inactive; painter->fillRect(option.rect, opt.backgroundBrush); }*/ //style->drawControl(QStyle::CE_ItemViewItem,&option,painter); QIcon::Mode im; if(isPaused || !(option.state & QStyle::State_Enabled)) { im = QIcon::Disabled; } else if(option.state & QStyle::State_Selected) { im = QIcon::Selected; } else { im = QIcon::Normal; } QIcon::State qs; if(isPaused) { qs = QIcon::Off; } else { qs = QIcon::On; } QPalette::ColorGroup cg = QPalette::Normal; if(isPaused || !(option.state & QStyle::State_Enabled)) { cg = QPalette::Disabled; } if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) { cg = QPalette::Inactive; } QPalette::ColorRole cr; if(option.state & QStyle::State_Selected) { cr = QPalette::HighlightedText; } cr = QPalette::Text; // layout const QSize m(margin(*style)); QRect fillArea(option.rect); fillArea.adjust(m.width(), m.height(), -m.width(), -m.height()); QRect iconArea(fillArea.x(), fillArea.y() + (fillArea.height() - iconSize) / 2, iconSize, iconSize); QRect nameArea(iconArea.x() + iconArea.width() + GUI_PAD, fillArea.y(), fillArea.width() - GUI_PAD - iconArea.width(), nameSize.height()); if (nameArea.width() + nameArea.x() > opt.rect.width()) { nameArea.setWidth(opt.rect.width() - nameArea.x()); } QRect barArea(nameArea.x(), nameArea.y() + statusFM.lineSpacing() + GUI_PAD / 2, nameArea.width(), BAR_HEIGHT); QRect progArea(nameArea.x(), barArea.y() + barArea.height() + GUI_PAD / 2, barArea.width() - statusWidth, nameArea.height()); QRect statusArea(progArea.x() + progArea.width(), progArea.y(), statusWidth, progArea.height()); if(tor.hasError()) { painter->setPen(QColor("red")); } else { painter->setPen(opt.palette.color(cg, cr)); } mimeIcon.paint(painter, iconArea, Qt::AlignCenter, im, qs); painter->setFont(nameFont); nameStr = nameFM.elidedText(nameStr, Qt::ElideRight, nameArea.width()); style->drawItemText(painter, nameArea, Qt::AlignLeft, opt.palette, option.state & QStyle::State_Enabled, nameStr); painter->setFont(statusFont); statusStr = statusFM.elidedText(statusStr, Qt::ElideRight, statusArea.width()); style->drawItemText(painter, statusArea, Qt::AlignRight, opt.palette, option.state & QStyle::State_Enabled, statusStr); painter->setFont(progressFont); progressStr = statusFM.elidedText(progressStr, Qt::ElideRight, progArea.width()); style->drawItemText(painter, progArea, Qt::AlignLeft, opt.palette, option.state & QStyle::State_Enabled, progressStr); int progressPercentage = tor.GetProgress(); myProgressBarStyle->resize(barArea.size()); myProgressBarStyle->setValue(progressPercentage); //painter->translate(barArea.topLeft()); //myProgressBarStyle->render(painter); QStyleOptionProgressBarV2 pbStyleOpt; myProgressBarStyle->initilizeStyleOption(&pbStyleOpt); pbStyleOpt.rect = barArea; /*myProgressBarStyle->rect = barArea; if ( tor.isDownloading() ) { myProgressBarStyle->palette.setBrush( QPalette::Highlight, blueBrush ); myProgressBarStyle->palette.setColor( QPalette::Base, blueBack ); myProgressBarStyle->palette.setColor( QPalette::Background, blueBack ); } else if ( tor.isSeeding() ) { myProgressBarStyle->palette.setBrush( QPalette::Highlight, greenBrush ); myProgressBarStyle->palette.setColor( QPalette::Base, greenBack ); myProgressBarStyle->palette.setColor( QPalette::Background, greenBack ); } myProgressBarStyle->state = progressBarState; setProgressBarPercentDone( option, tor ); */ style->drawControl(QStyle::CE_ProgressBar, &pbStyleOpt, painter, myProgressBarStyle); painter->restore(); }