/*! Construct an AT-based SIM information object for \a service. */ QModemSimInfo::QModemSimInfo( QModemService *service ) : QSimInfo( service->service(), service, QCommInterface::Server ) { d = new QModemSimInfoPrivate(); d->service = service; d->checkTimer = new QTimer( this ); d->checkTimer->setSingleShot( true ); connect( d->checkTimer, SIGNAL(timeout()), this, SLOT(requestIdentity()) ); d->count = 0; d->simPinRequired = false; // Perform an initial AT+CIMI request to get the SIM identity. QTimer::singleShot( 0, this, SLOT(requestIdentity()) ); // Hook onto the posted event of the service to determine // the current sim pin status connect( service, SIGNAL(posted(QString)), this, SLOT(serviceItemPosted(QString)) ); }
static unsigned table1 (unsigned margin, char const * string, struct column * column) { extern unsigned line; extern char const * style; extern char const * style_empty; extern char const * label_empty; struct column * object; line = 1; headers (column); indent (margin++, "<table class='%s'>", style); indent (margin++, "<tr class='%s'>", style); indent (margin++, "<th class='%s'>", style); indent (margin, "%s", column->name); indent (margin--, "</th>"); for (object = column ->next; object; object = object ->next) { indent (margin++, "<th class='%s'>", style); indent (margin, "%s", object->name); indent (margin--, "</th>"); } indent (margin--, "</tr>"); for (columns (column); ! feof (stdin); columns (column)) { indent (margin++, "<tr class='%s'>", style); indent (margin++, "<td class='%s'>", style); indent (margin, "%s", column->name); indent (margin--, "</td>"); for (object = column ->next; object; object = object ->next) { indent (margin++, "<td class='%s'>", object ->style); indent (margin, "%s", object ->label); indent (margin--, "</td>"); object->style = style_empty; object->label = label_empty; } indent (margin--, "</tr>"); } indent (margin--, "</table>"); posted (margin); finish (column); return (margin); }
bool printMulticopyDocument::sPostOneDoc(XSqlQuery *docq) { if (! _postQuery.isEmpty() && _data->_post->isChecked() && isOnPrintedList(docq->value("docid").toInt()) && ! docq->value("posted").toBool()) { QString docnumber = docq->value("docnumber").toString(); message(tr("Posting %1 #%2").arg(_data->_doctypefull, docnumber)); ParameterList postp; postp.append("docid", docq->value("docid")); postp.append("docnumber", docq->value("docnumber")); if (! _askBeforePostingQry.isEmpty()) { MetaSQLQuery askm(_askBeforePostingQry); XSqlQuery askq = askm.toQuery(postp); if (ErrorReporter::error(QtCriticalMsg, this, tr("Cannot Post %1").arg(docnumber), askq, __FILE__, __LINE__)) return false; else if (askq.value("ask").toBool() && QMessageBox::question(this, tr("Post Anyway?"), _askBeforePostingMsg.arg(docnumber), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) return false; } if (! _errCheckBeforePostingQry.isEmpty()) { MetaSQLQuery errm(_errCheckBeforePostingQry); XSqlQuery errq = errm.toQuery(postp); if (ErrorReporter::error(QtCriticalMsg, this, tr("Cannot Post %1").arg(docnumber), errq, __FILE__, __LINE__)) return false; else if (! errq.first() || ! errq.value("ok").toBool()) { ErrorReporter::error(QtCriticalMsg, this, tr("Cannot Post %1").arg(docnumber), _errCheckBeforePostingMsg, __FILE__, __LINE__); return false; } } //TODO: find a way to do this without holding locks during user input XSqlQuery("BEGIN;"); XSqlQuery rollback; rollback.prepare("ROLLBACK;"); MetaSQLQuery postm(_postQuery); XSqlQuery postq = postm.toQuery(postp); if (postq.first()) { int result = postq.value("result").toInt(); if (result < 0) { rollback.exec(); ErrorReporter::error(QtCriticalMsg, this, tr("Cannot Post %1").arg(docnumber), storedProcErrorLookup(_postFunction, result), __FILE__, __LINE__); return false; } if (_distributeInventory && (distributeInventory::SeriesAdjust(result, this) == XDialog::Rejected)) { rollback.exec(); QMessageBox::information(this, tr("Posting Canceled"), tr("Transaction Canceled") ); return false; } } else if (postq.lastError().type() != QSqlError::NoError) { rollback.exec(); ErrorReporter::error(QtCriticalMsg, this, tr("Cannot Post %1").arg(docnumber), postq, __FILE__, __LINE__); return false; } XSqlQuery("COMMIT;"); emit posted(_data->_docid); } return true; }
void Post::postComment() { const Record *r=(const Record *)commentS->currentData().value<quintptr>(); QNetworkRequest request; QByteArray data; const Comment &c=getComment(); switch(Utils::parseSite(r->source)){ case Utils::Bilibili: { QString api("http://interface.%1/dmpost"); api=api.arg(Utils::customUrl(Utils::Bilibili)); request.setUrl(api); request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); QUrlQuery params; params.addQueryItem("cid",QFileInfo(r->source).baseName()); params.addQueryItem("date",QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); params.addQueryItem("pool","0"); params.addQueryItem("playTime",QString::number((c.time-r->delay)/1000.0,'f',4)); params.addQueryItem("color",QString::number(c.color)); params.addQueryItem("fontsize",QString::number(c.font)); params.addQueryItem("message",c.string); params.addQueryItem("rnd",QString::number(qrand())); params.addQueryItem("mode",QString::number(c.mode)); data=QUrl::toPercentEncoding(params.query(QUrl::FullyEncoded),"%=&","-.~_"); break; } case Utils::AcPlay: { QString api("http://api.%1/api/v1/comment/%2"); api=api.arg(Utils::customUrl(Utils::AcPlay)); api=api.arg(QFileInfo(r->source).baseName()); request.setUrl(api); request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json"); QJsonObject params; params["Token"]=0; params["Time"]=(c.time-r->delay)/1000.0; params["Mode"]=c.mode; params["Color"]=c.color; params["TimeStamp"]=QDateTime::currentMSecsSinceEpoch(); params["Pool"]=0; params["UId"]=0; params["CId"]=0; params["Message"]=c.string; data=QJsonDocument(params).toJson(); break; } default: break; } Danmaku::instance()->appendToPool(r->source,&c); QNetworkReply *reply=manager->post(request,data); connect(reply,&QNetworkReply::finished,[=](){ int error=reply->error(); if (error==QNetworkReply::NoError){ switch(Utils::parseSite(reply->url().url())) { case Utils::Bilibili: { error=qMin<int>(QString(reply->readAll()).toInt(),QNetworkReply::NoError); break; } case Utils::AcPlay: { QJsonObject o=QJsonDocument::fromJson(reply->readAll()).object(); error=o["Success"].toBool()?QNetworkReply::NoError:QNetworkReply::UnknownNetworkError; break; } default: break; } } if(error!=QNetworkReply::NoError){ QString info=tr("Network error occurred, error code: %1").arg(error); QString sugg=Local::instance()->suggestion(error); QMessageBox::warning(lApp->mainWidget(),tr("Network Error"),sugg.isEmpty()?info:(info+'\n'+sugg)); } else{ emit posted(&c); } reply->deleteLater(); }); }