void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* properties) { ScriptFunctionCall function(m_injectedScriptObject, "getProperties"); function.appendArgument(objectId); function.appendArgument(ignoreHasOwnProperty); RefPtr<InspectorValue> result; makeCall(function, &result); if (!result || result->type() != InspectorValue::TypeArray) { *errorString = "Internal error"; return; } *properties = result->asArray(); }
void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr<InspectorArray>* properties) { ScriptFunctionCall function(m_injectedScriptObject, "getProperties"); function.appendArgument(objectId); function.appendArgument(ownProperties); RefPtr<InspectorValue> result; makeCall(function, &result); if (!result || result->type() != InspectorValue::TypeArray) { *errorString = "Internal error"; return; } *properties = Array<PropertyDescriptor>::runtimeCast(result); }
void InjectedScriptCanvasModule::resourceState(ErrorString* errorString, const TraceLogId& traceLogId, const ResourceId& resourceId, RefPtr<ResourceState>* result) { ScriptFunctionCall function(injectedScriptObject(), "resourceState"); function.appendArgument(traceLogId); function.appendArgument(resourceId); RefPtr<InspectorValue> resultValue; makeCall(function, &resultValue); if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { if (!resultValue->asString(errorString)) *errorString = "Internal error: resourceState"; return; } *result = ResourceState::runtimeCast(resultValue); }
void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr<Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>>* properties) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getProperties"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(objectId); function.appendArgument(ownProperties); RefPtr<InspectorValue> result; makeCall(function, &result); if (!result || result->type() != InspectorValue::TypeArray) { *errorString = ASCIILiteral("Internal error"); return; } *properties = Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>::runtimeCast(result); }
void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<Inspector::TypeBuilder::Debugger::FunctionDetails>* result) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getFunctionDetails"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(functionId); RefPtr<InspectorValue> resultValue; makeCall(function, &resultValue); if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { if (!resultValue->asString(errorString)) *errorString = ASCIILiteral("Internal error"); return; } *result = Inspector::TypeBuilder::Debugger::FunctionDetails::runtimeCast(resultValue); }
void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, RefPtr<Array<InternalPropertyDescriptor> >* properties) { ScriptFunctionCall function(injectedScriptObject(), "getInternalProperties"); function.appendArgument(objectId); RefPtr<JSONValue> result; makeCall(function, &result); if (!result || result->type() != JSONValue::TypeArray) { *errorString = "Internal error"; return; } RefPtr<Array<InternalPropertyDescriptor> > array = Array<InternalPropertyDescriptor>::runtimeCast(result); if (array->length() > 0) *properties = array; }
void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, RefPtr<Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>>* properties) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getInternalProperties"), inspectorEnvironment()->functionCallHandler()); function.appendArgument(objectId); RefPtr<InspectorValue> result; makeCall(function, &result); if (!result || result->type() != InspectorValue::Type::Array) { *errorString = ASCIILiteral("Internal error"); return; } auto array = BindingTraits<Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>>::runtimeCast(result); if (array->length() > 0) *properties = array; }
void InjectedScriptCanvasModule::traceLog(ErrorString* errorString, const TraceLogId& traceLogId, const int* startOffset, const int* maxLength, RefPtr<TraceLog>* traceLog) { Deprecated::ScriptFunctionCall function(injectedScriptObject(), "traceLog", WebCore::functionCallHandlerFromAnyThread); function.appendArgument(traceLogId); if (startOffset) function.appendArgument(*startOffset); if (maxLength) function.appendArgument(*maxLength); RefPtr<InspectorValue> resultValue; makeCall(function, &resultValue); if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { if (!resultValue->asString(errorString)) *errorString = "Internal error: traceLog"; return; } *traceLog = TraceLog::runtimeCast(resultValue); }
static inline libblock::Code *makeCall2( T name, libblock::Code *left, libblock::Code *right ) { if (!left || !right) { // TODO: ??? throw; } else if (left->getNext() || right->getNext()) { // TODO: anonymous struct (tuple) throw; } else { return makeCall( std::forward<T>(name), libblock::Code::pack(left, right) ); } }
void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String& callFrameId) { ScriptFunctionCall function(injectedScriptObject(), "restartFrame"); function.appendArgument(callFrames); function.appendArgument(callFrameId); RefPtr<JSONValue> resultValue; makeCall(function, &resultValue); if (resultValue) { if (resultValue->type() == JSONValue::TypeString) { resultValue->asString(errorString); } else { bool value; ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); } return; } *errorString = "Internal error"; }
void So2sdrBandmap::timerEvent(QTimerEvent *event) { if (event->timerId() == timerId[0]) { // update frequency spectrumProcessor->resetAvg(); makeCall(); CallLabel->setPixmap(callPixmap); CallLabel->update(); } else if (event->timerId() == timerId[1]) { // UDP beacon writeUdpXML(0,"",false); } else if (event->timerId() == timerId[2]) { // update IQ balance plot if (settings->value(s_sdr_type,s_sdr_type_def).toInt()==soundcard_t) { calc(); } } }
void InjectedScript::restartFrame(ErrorString* errorString, const ScriptValue& callFrames, const String& callFrameId, RefPtr<JSONObject>* result) { ScriptFunctionCall function(injectedScriptObject(), "restartFrame"); function.appendArgument(callFrames); function.appendArgument(callFrameId); RefPtr<JSONValue> resultValue; makeCall(function, &resultValue); if (resultValue) { if (resultValue->type() == JSONValue::TypeString) { resultValue->asString(errorString); return; } if (resultValue->type() == JSONValue::TypeObject) { *result = resultValue->asObject(); return; } } *errorString = "Internal error"; }
void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::Location>>& positions) { ScriptFunctionCall function(injectedScriptObject(), "getStepInPositions"); function.appendArgument(callFrames); function.appendArgument(callFrameId); RefPtr<JSONValue> resultValue; makeCall(function, &resultValue); if (resultValue) { if (resultValue->type() == JSONValue::TypeString) { resultValue->asString(errorString); return; } if (resultValue->type() == JSONValue::TypeArray) { positions = Array<TypeBuilder::Debugger::Location>::runtimeCast(resultValue); return; } } *errorString = "Internal error"; }
void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr<Protocol::Runtime::RemoteObject>* objectResult, Protocol::OptOutput<bool>* wasThrown, Protocol::OptOutput<int>* savedResultIndex) { RefPtr<JSON::Value> result; makeCall(function, &result); if (!result) { errorString = ASCIILiteral("Internal error: result value is empty"); return; } if (result->type() == JSON::Value::Type::String) { result->asString(errorString); ASSERT(errorString.length()); return; } RefPtr<JSON::Object> resultTuple; if (!result->asObject(resultTuple)) { errorString = ASCIILiteral("Internal error: result is not an Object"); return; } RefPtr<JSON::Object> resultObject; if (!resultTuple->getObject(ASCIILiteral("result"), resultObject)) { errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag"); return; } bool wasThrownValue = false; if (!resultTuple->getBoolean(ASCIILiteral("wasThrown"), wasThrownValue)) { errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag"); return; } *objectResult = BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject); *wasThrown = wasThrownValue; if (savedResultIndex) { int savedIndex = 0; if (resultTuple->getInteger(ASCIILiteral("savedResultIndex"), savedIndex)) *savedResultIndex = savedIndex; } }
PTREE AnalyseDtorCall( // ANALYSIS FOR SPECIAL DTOR CALLS TYPE class_type, // - class to be destructed PTREE this_node, // - expression for address of class target_offset_t extra ) // - constant for extra second parm { SEARCH_RESULT *result; // - search results SYMBOL dtor_sym; // - DTOR symbol PTREE dtor_id; // - node for dtor symbol PTREE expr; // - expression under construction TYPE return_type; // - type of return boolean virtual_call; // - TRUE ==> virtual dtor TOKEN_LOCN err_locn; // - error location /* assumes class_type->u.c.info->needs_dtor is TRUE */ result = DtorFindResult( class_type ); PTreeExtractLocn( this_node, &err_locn ); ScopeResultErrLocn( result, &err_locn ); dtor_sym = result->sym_name->name_syms; ScopeCheckSymbol( result, dtor_sym ); dtor_id = NodeSymbolCallee( PTreeAlloc(), dtor_sym, result ); virtual_call = adjustForVirtualCall( &this_node, &dtor_id, result ); return_type = SymFuncReturnType( dtor_sym ); expr = makeCall( dtor_id, return_type, NULL, ! virtual_call ); this_node = NodeArg( this_node ); if( virtual_call ) { this_node->flags |= PTF_ARG_THIS_VFUN; } expr = CallArgsArrange( dtor_sym->sym_type , expr , NULL , this_node , NodeArg( NodeCDtorArg( extra ) ) , NULL ); if( virtual_call ) { expr->u.subtree[0] = VfnDecorateCall( expr->u.subtree[0], dtor_sym ); } expr->flags |= PTF_MEANINGFUL | PTF_SIDE_EFF; return expr; }
/// Create the transient representation of an object. StatusCode PersistencySvc::createObj(IOpaqueAddress* pAddr, DataObject*& refpObj) { return makeCall(CREATE_OBJ, pAddr, refpObj); }
/// Update the transient object from the other representation. StatusCode PersistencySvc::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) { return makeCall(UPDATE_OBJ, pAddr, pObj); }
void launch_server() { int s = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in a; memset(&a, 0, sizeof(struct sockaddr_in)); a.sin_family = AF_INET; a.sin_port = 0; if((a.sin_addr.s_addr = getPublicIPAddr()) == 0) { fprintf(stderr, "Could not get public ip address. Exiting...\n"); exit(0); } if(mybind(s, &a) < 0) { fprintf(stderr, "mybind() failed. Exiting...\n"); exit(0); } printf("%s %u\n", inet_ntoa(a.sin_addr), ntohs(a.sin_port)); if(listen(s, 0) < 0) { perror("listen"); exit(0); } memset(&a, 0, sizeof(struct sockaddr_in)); socklen_t alen = sizeof(struct sockaddr_in); int asock = -1; while((asock = accept(s, (struct sockaddr *)&a, &alen)) > 0) { /* Single-threaded */ char *fname; int nparams; arg_type *a = NULL; return_type ret; recvCall(asock, &fname, &nparams, &a); #ifdef _DEBUG_1_ printf("launch_server(), before makeCall()\n"); fflush(stdout); #endif makeCall(fname, nparams, a, &ret); #ifdef _DEBUG_1_ printf("launch_server(), after makeCall()\n"); fflush(stdout); #endif returnResult(asock, &ret); free(fname); freeArgs(a); freeRet(ret); shutdown(asock, SHUT_RDWR); close(asock); asock = -1; } /* WARNING -- massive memory, linked list of registered * functions! We assume that the process exits at this * point, and so do not bother freeing the memory. */ return; }
/// Convert the transient object to the requested representation. StatusCode PersistencySvc::createRep(DataObject* pObj, IOpaqueAddress*& refpAddr) { return makeCall(CREATE_REP, refpAddr, pObj); }
/// Resolve the references of the converted object. StatusCode PersistencySvc::fillRepRefs(IOpaqueAddress* pAddr, DataObject* pObj) { return makeCall(FILL_REP_REFS, pAddr, pObj); }
/// Update the references of an already converted object. StatusCode PersistencySvc::updateRepRefs(IOpaqueAddress* pAddr, DataObject* pObj) { return makeCall(UPDATE_REP_REFS, pAddr, pObj); }
void CMessageBrokerControllerPhone::processRequest(Json::Value& root) { DBG_MSG(("CMessageBrokerControllerPhone::processRequest()\n")); if (getControllersName() == getDestinationComponentName(root)) { Json::Value response; response["jsonrpc"] = root["jsonrpc"]; response["id"] = root["id"]; if ("makeCall" == getMethodName(root)) { if (root.isMember("params")) { Json::Value params = root["params"]; if (params.isMember("phoneNumber") && params["phoneNumber"].isString()) { makeCall(params["phoneNumber"].asString(), response); } else { DBG_MSG_ERROR(("Wrong params!\n")); prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Wrong params!", response); } } else { DBG_MSG_ERROR(("Not possible to parse phone number!\n")); prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Not possible to parse phone number!", response); } } else if ("endCall" == getMethodName(root)) { endCall(root["params"].asString(), response); } else if ("holdCall" == getMethodName(root)) { holdCall(root["params"].asString(), response); } else if ("getContacts" == getMethodName(root)) { if (root.isMember("params")) { Json::Value params = root["params"]; if (params.isMember("firstLetter") && params["firstLetter"].isString() && params.isMember("offset") && params["offset"].isInt() && params.isMember("numberOfItems") && params["numberOfItems"].isInt()) { getContacts(params["firstLetter"].asString(), params["offset"].asInt(), params["numberOfItems"].asInt(), response); } else { DBG_MSG_ERROR(("Wrong params of getContacts()!\n")); prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Wrong params of getContacts()!", response); } } else { DBG_MSG_ERROR(("Params is not an object!\n")); prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Params is not an object!", response); } } else if ("getHistory" == getMethodName(root)) { if (root.isMember("params")) { Json::Value params = root["params"]; if (params.isMember("typeOfContacts") && params["typeOfContacts"].isString() && params.isMember("offset") && params["offset"].isInt() && params.isMember("numberOfItems") && params["numberOfItems"].isInt()) { getHistory(params["typeOfContacts"].asString(), params["offset"].asInt(), params["numberOfItems"].asInt(), response); } else { DBG_MSG_ERROR(("Wrong params of getHistory()!\n")); prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Wrong params of getHistory()!", response); } } else { DBG_MSG_ERROR(("Params is not an object!\n")); prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Params is not an object!", response); } } else { DBG_MSG_ERROR(("Method has not been found!\n")); Json::Value err; err["code"] = NsMessageBroker::INVALID_REQUEST; err["message"] = "Method has not been found."; response["error"] = err; } sendJsonMessage(response); } else { DBG_MSG_ERROR(("Wrong message destination!\n")); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), preferences(NULL), _consoleWindow(NULL), _stateDebugDialog(NULL) { ui->setupUi(this); /* Setup the taskbar icon */ sysTray = new QSystemTrayIcon(QIcon(":/images/taskbar_icon"), this); sysTray->setToolTip(tr("FSComm")); /* Connect DTMF buttons */ dialpadMapper = new QSignalMapper(this); connect(ui->dtmf0Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf1Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf2Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf3Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf4Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf5Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf6Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf7Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf8Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmf9Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmfABtn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmfBBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmfCBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmfDBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmfAstBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); connect(ui->dtmfPoundBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map())); dialpadMapper->setMapping(ui->dtmf0Btn, QString("0")); dialpadMapper->setMapping(ui->dtmf1Btn, QString("1")); dialpadMapper->setMapping(ui->dtmf2Btn, QString("2")); dialpadMapper->setMapping(ui->dtmf3Btn, QString("3")); dialpadMapper->setMapping(ui->dtmf4Btn, QString("4")); dialpadMapper->setMapping(ui->dtmf5Btn, QString("5")); dialpadMapper->setMapping(ui->dtmf6Btn, QString("6")); dialpadMapper->setMapping(ui->dtmf7Btn, QString("7")); dialpadMapper->setMapping(ui->dtmf8Btn, QString("8")); dialpadMapper->setMapping(ui->dtmf9Btn, QString("9")); dialpadMapper->setMapping(ui->dtmfABtn, QString("A")); dialpadMapper->setMapping(ui->dtmfBBtn, QString("B")); dialpadMapper->setMapping(ui->dtmfCBtn, QString("C")); dialpadMapper->setMapping(ui->dtmfDBtn, QString("D")); dialpadMapper->setMapping(ui->dtmfAstBtn, QString("*")); dialpadMapper->setMapping(ui->dtmfPoundBtn, QString("#")); connect(dialpadMapper, SIGNAL(mapped(QString)), this, SLOT(sendDTMF(QString))); /* Connect events related to FreeSWITCH */ connect(g_FSHost, SIGNAL(ready()),this, SLOT(fshostReady())); connect(g_FSHost, SIGNAL(ringing(QSharedPointer<Call>)), this, SLOT(ringing(QSharedPointer<Call>))); connect(g_FSHost, SIGNAL(answered(QSharedPointer<Call>)), this, SLOT(answered(QSharedPointer<Call>))); connect(g_FSHost, SIGNAL(hungup(QSharedPointer<Call>)), this, SLOT(hungup(QSharedPointer<Call>))); connect(g_FSHost, SIGNAL(newOutgoingCall(QSharedPointer<Call>)), this, SLOT(newOutgoingCall(QSharedPointer<Call>))); connect(g_FSHost, SIGNAL(callFailed(QSharedPointer<Call>)), this, SLOT(callFailed(QSharedPointer<Call>))); connect(g_FSHost, SIGNAL(accountStateChange(QSharedPointer<Account>)), this, SLOT(accountStateChanged(QSharedPointer<Account>))); connect(g_FSHost, SIGNAL(newAccount(QSharedPointer<Account>)), this, SLOT(accountAdd(QSharedPointer<Account>))); connect(g_FSHost, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountDel(QSharedPointer<Account>))); connect(g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString))); /* Connect call commands */ connect(ui->newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall())); connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer())); connect(ui->hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup())); connect(ui->recoredCallBtn, SIGNAL(toggled(bool)), SLOT(recordCall(bool))); connect(ui->btnHold, SIGNAL(toggled(bool)), this, SLOT(holdCall(bool))); /*connect(ui->btnTransfer, SIGNAL(clicked()), this, SLOT(transferCall()));*/ connect(ui->tableCalls, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(callTableDoubleClick(QTableWidgetItem*))); connect(ui->action_Preferences, SIGNAL(triggered()), this, SLOT(prefTriggered())); connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionConsole, SIGNAL(triggered()), this, SLOT(debugConsoleTriggered())); connect(ui->actionEvents, SIGNAL(triggered()), this, SLOT(debugEventsTriggered())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAbout())); connect(ui->actionSetDefaultAccount, SIGNAL(triggered(bool)), this, SLOT(setDefaultAccount())); connect(sysTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(sysTrayActivated(QSystemTrayIcon::ActivationReason))); /* Set the context menus */ ui->tableAccounts->addAction(ui->actionSetDefaultAccount); /* Set other properties */ ui->tableAccounts->horizontalHeader()->setStretchLastSection(true); /* Set the call timer */ callTimer = new QTimer(this); callTimer->setInterval(1000); connect(callTimer, SIGNAL(timeout()), this, SLOT(updateCallTimers())); callTimer->start(); }
void cocon_log_Callback(const collaborative_control::cocon_m::ConstPtr& msg){ cocon=*msg; makeCall(); }
void KDSoapServerSocket::slotReadyRead() { if (!m_socketEnabled) return; //qDebug() << this << QThread::currentThread() << "slotReadyRead!"; QByteArray buf(2048, ' '); qint64 nread = -1; while (nread != 0) { nread = read(buf.data(), buf.size()); if (nread < 0) { qDebug() << "Error reading from server socket:" << errorString(); return; } m_requestBuffer += buf.left(nread); } //qDebug() << "KDSoapServerSocket: request:" << m_requestBuffer; QByteArray receivedHttpHeaders, receivedData; const bool splitOK = splitHeadersAndData(m_requestBuffer, receivedHttpHeaders, receivedData); if (!splitOK) { //qDebug() << "Incomplete SOAP request, wait for more data"; //incomplete request, wait for more data return; } QMap<QByteArray, QByteArray> httpHeaders; httpHeaders = parseHeaders(receivedHttpHeaders); if (m_doDebug) { qDebug() << "headers received:" << receivedHttpHeaders; qDebug() << httpHeaders; qDebug() << "data received:" << receivedData; } const QByteArray contentLength = httpHeaders.value("content-length"); if (receivedData.size() < contentLength.toInt()) return; // incomplete request, wait for more data m_requestBuffer.clear(); const QByteArray requestType = httpHeaders.value("_requestType"); if (requestType != "GET" && requestType != "POST") { qWarning() << "Unknown HTTP request:" << requestType; //handleError(replyMsg, "Client.Data", QString::fromLatin1("Invalid request type '%1', should be GET or POST").arg(QString::fromLatin1(requestType.constData()))); //sendReply(0, replyMsg); const QByteArray methodNotAllowed = "HTTP/1.1 405 Method Not Allowed\r\nAllow: GET POST\r\nContent-Length: 0\r\n\r\n"; write(methodNotAllowed); return; } const QString path = QString::fromLatin1(httpHeaders.value("_path").constData()); KDSoapServerAuthInterface* serverAuthInterface = qobject_cast<KDSoapServerAuthInterface *>(m_serverObject); if (serverAuthInterface) { QByteArray authValue = httpHeaders.value("Authorization"); if (authValue.isEmpty()) authValue = httpHeaders.value("authorization"); // as sent by Qt-4.5 if (!serverAuthInterface->handleHttpAuth(authValue, path)) { // send auth request (Qt supports basic, ntlm and digest) const QByteArray unauthorized = "HTTP/1.1 401 Authorization Required\r\nWWW-Authenticate: Basic realm=\"example\"\r\nContent-Length: 0\r\n\r\n"; write(unauthorized); return; } } KDSoapServer* server = m_owner->server(); KDSoapMessage replyMsg; replyMsg.setUse(server->use()); KDSoapServerObjectInterface* serverObjectInterface = qobject_cast<KDSoapServerObjectInterface *>(m_serverObject); if (!serverObjectInterface) { const QString error = QString::fromLatin1("Server object %1 does not implement KDSoapServerObjectInterface!").arg(QString::fromLatin1(m_serverObject->metaObject()->className())); handleError(replyMsg, "Server.ImplementationError", error); sendReply(0, replyMsg); return; } else { serverObjectInterface->setServerSocket(this); } if (requestType == "GET") { if (path == server->wsdlPathInUrl() && handleWsdlDownload()) { return; } else if (handleFileDownload(serverObjectInterface, path)) { return; } // See http://www.ibm.com/developerworks/xml/library/x-tipgetr/ // We could implement it, but there's no SOAP request, just a query in the URL, // which we'd have to pass to a different virtual than processRequest. handleError(replyMsg, "Client.Data", QString::fromLatin1("Support for GET requests not implemented yet.")); sendReply(0, replyMsg); return; } //parse message KDSoapMessage requestMsg; KDSoapHeaders requestHeaders; KDSoapMessageReader reader; KDSoapMessageReader::XmlError err = reader.xmlToMessage(receivedData, &requestMsg, &m_messageNamespace, &requestHeaders); if (err == KDSoapMessageReader::PrematureEndOfDocumentError) { //qDebug() << "Incomplete SOAP message, wait for more data"; // This should never happen, since we check for content-size above. return; } //TODO handle parse errors? // check soap version and extract soapAction header QByteArray soapAction; const QByteArray contentType = httpHeaders.value("content-type"); if (contentType.startsWith("text/xml")) { // SOAP 1.1 soapAction = httpHeaders.value("soapaction"); // The SOAP standard allows quotation marks around the SoapAction, so we have to get rid of these. if (soapAction.startsWith('\"')) soapAction = soapAction.mid(1, soapAction.length() - 2); } else if (contentType.startsWith("application/soap+xml")) { // SOAP 1.2 // Example: application/soap+xml;charset=utf-8;action=ActionHex const QList<QByteArray> parts = contentType.split(';'); Q_FOREACH(const QByteArray& part, parts) { if (part.startsWith("action=")) { soapAction = part.mid(strlen("action=")); } } } m_method = requestMsg.name(); if (!replyMsg.isFault()) { makeCall(serverObjectInterface, requestMsg, replyMsg, requestHeaders, soapAction, path); } if (serverObjectInterface && m_delayedResponse) { // Delayed response. Disable the socket to make sure we don't handle another call at the same time. setSocketEnabled(false); } else { sendReply(serverObjectInterface, replyMsg); } }
AST_expr* remapListComp(AST_ListComp* node) { std::string rtn_name = nodeName(node); push_back(makeAssign(rtn_name, new AST_List())); std::vector<CFGBlock*> exit_blocks; // Where the current level should jump to after finishing its iteration. // For the outermost comprehension, this is NULL, and it doesn't jump anywhere; // for the inner comprehensions, they should jump to the next-outer comprehension // when they are done iterating. CFGBlock *finished_block = NULL; for (int i = 0, n = node->generators.size(); i < n; i++) { AST_comprehension *c = node->generators[i]; bool is_innermost = (i == n-1); AST_expr *remapped_iter = remapExpr(c->iter); AST_expr *iter_attr = makeLoadAttribute(remapped_iter, "__iter__", true); AST_expr *iter_call = makeCall(iter_attr); std::string iter_name = nodeName(node, "iter", i); AST_stmt *iter_assign = makeAssign(iter_name, iter_call); push_back(iter_assign); // TODO bad to save these like this? AST_expr *hasnext_attr = makeLoadAttribute(makeName(iter_name, AST_TYPE::Load), "__hasnext__", true); AST_expr *next_attr = makeLoadAttribute(makeName(iter_name, AST_TYPE::Load), "next", true); AST_Jump *j; CFGBlock *test_block = cfg->addBlock(); test_block->info = "listcomp_test"; //printf("Test block for comp %d is %d\n", i, test_block->idx); j = new AST_Jump(); j->target = test_block; curblock->connectTo(test_block); push_back(j); curblock = test_block; AST_expr *test_call = makeCall(hasnext_attr); CFGBlock* body_block = cfg->addBlock(); body_block->info = "listcomp_body"; CFGBlock* exit_block = cfg->addDeferredBlock(); exit_block->info = "listcomp_exit"; exit_blocks.push_back(exit_block); //printf("Body block for comp %d is %d\n", i, body_block->idx); AST_Branch *br = new AST_Branch(); br->col_offset = node->col_offset; br->lineno = node->lineno; br->test = test_call; br->iftrue = body_block; br->iffalse = exit_block; curblock->connectTo(body_block); curblock->connectTo(exit_block); push_back(br); curblock = body_block; push_back(makeAssign(c->target, makeCall(next_attr))); for (AST_expr *if_condition : c->ifs) { AST_expr *remapped = remapExpr(if_condition); AST_Branch *br = new AST_Branch(); br->test = remapped; push_back(br); // Put this below the entire body? CFGBlock *body_tramp = cfg->addBlock(); body_tramp->info = "listcomp_if_trampoline"; //printf("body_tramp for %d is %d\n", i, body_tramp->idx); CFGBlock *body_continue = cfg->addBlock(); body_continue->info = "listcomp_if_continue"; //printf("body_continue for %d is %d\n", i, body_continue->idx); br->iffalse = body_tramp; curblock->connectTo(body_tramp); br->iftrue = body_continue; curblock->connectTo(body_continue); curblock = body_tramp; j = new AST_Jump(); j->target = test_block; push_back(j); curblock->connectTo(test_block, true); curblock = body_continue; } CFGBlock *body_end = curblock; assert((finished_block != NULL) == (i != 0)); if (finished_block) { curblock = exit_block; j = new AST_Jump(); j->target = finished_block; curblock->connectTo(finished_block, true); push_back(j); } finished_block = test_block; curblock = body_end; if (is_innermost) { AST_expr *elt = remapExpr(node->elt); push_back(makeExpr(makeCall(makeLoadAttribute(makeName(rtn_name, AST_TYPE::Load), "append", true), elt))); j = new AST_Jump(); j->target = test_block; curblock->connectTo(test_block, true); push_back(j); assert(exit_blocks.size()); curblock = exit_blocks[0]; } else { // continue onto the next comprehension and add to this body } } // Wait until the end to place the end blocks, so that // we get a nice nesting structure, that looks similar to what // you'd get with a nested for loop: for (int i = exit_blocks.size() - 1; i >= 0; i--) { cfg->placeBlock(exit_blocks[i]); //printf("Exit block for comp %d is %d\n", i, exit_blocks[i]->idx); } return makeName(rtn_name, AST_TYPE::Load); };