bool HTMLObjectElement::hasValidClassId() { #if PLATFORM(QT) if (equalIgnoringCase(serviceType(), "application/x-qt-plugin") || equalIgnoringCase(serviceType(), "application/x-qt-styled-widget")) return true; #endif if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType()) && classId().startsWith("java:", false)) return true; // HTML5 says that fallback content should be rendered if a non-empty // classid is specified for which the UA can't find a suitable plug-in. return classId().isEmpty(); }
bool HTMLObjectElement::hasValidClassId() { #if PLATFORM(QT) if (isQtPluginServiceType(serviceType())) return true; #endif if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType()) && classId().startsWith("java:", false)) return true; if (shouldAllowQuickTimeClassIdQuirk()) return true; // HTML5 says that fallback content should be rendered if a non-empty // classid is specified for which the UA can't find a suitable plug-in. return classId().isEmpty(); }
inline bool HTMLObjectElement::hasValidClassId() { // HTML5 says that fallback content should be rendered if a non-empty // classid is specified for which the UA can't find a suitable plug-in. // WebKit supports no classids, with the exception of Qt plug-ins, which use // classid to specify which QObject to load. #if PLATFORM(QT) return classId().isEmpty() || equalIgnoringCase(serviceType(), "application/x-qt-plugin") || equalIgnoringCase(serviceType(), "application/x-qt-styled-widget"); #else return classId().isEmpty(); #endif }
bool HTMLObjectElement::hasValidClassId() { #if PLATFORM(QT) if (equalIgnoringCase(serviceType(), "application/x-qt-plugin") || equalIgnoringCase(serviceType(), "application/x-qt-styled-widget")) return true; //+EAWebKitChange //10/14/2011 - Do we really need this change? #elif PLATFORM(EA) if (equalIgnoringCase(serviceType(), "application/x-ea-plugin") || equalIgnoringCase(serviceType(), "application/x-ea-styled-widget")) return true; #endif //-EAWebKitChange if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType()) && classId().startsWith("java:", false)) return true; if (shouldAllowQuickTimeClassIdQuirk()) return true; // HTML5 says that fallback content should be rendered if a non-empty // classid is specified for which the UA can't find a suitable plug-in. return classId().isEmpty(); }
bool HClientServiceAdapter::setService( HClientService* service, ValidationType vt) { HResourceType st = service->info().serviceType(); if (!service || !st.compare(serviceType(), HResourceType::Inclusive)) { setLastErrorDescription(QString("Unsupported service type: [%1]").arg(st.toString())); return false; } if (vt == FullValidation) { if (deviceModelInfoProvider()) { if (!h_ptr->validate(service)) { return false; } } } if (!prepareService(service)) { return false; } h_ptr->m_service = service; if (deviceModelInfoProvider()) { HActionsSetupData actionsSetupData = deviceModelInfoProvider()->actionsSetupData( service->info(), service->parentDevice()->info()); if (!actionsSetupData.isEmpty()) { h_ptr->m_actionsSetupData.reset( new HActionsSetupData(actionsSetupData)); } } return true; }
bool QXmppSaslClientDigestMd5::respond(const QByteArray &challenge, QByteArray &response) { Q_UNUSED(challenge); const QByteArray digestUri = QString("%1/%2").arg(serviceType(), host()).toUtf8(); if (m_step == 0) { response = QByteArray(); m_step++; return true; } else if (m_step == 1) { const QMap<QByteArray, QByteArray> input = QXmppSaslDigestMd5::parseMessage(challenge); if (!input.contains("nonce")) { warning("QXmppSaslClientDigestMd5 : Invalid input on step 1"); return false; } // determine realm const QByteArray realm = input.value("realm"); // determine quality of protection const QList<QByteArray> qops = input.value("qop", "auth").split(','); if (!qops.contains("auth")) { warning("QXmppSaslClientDigestMd5 : Invalid quality of protection"); return false; } m_nonce = input.value("nonce"); m_secret = QCryptographicHash::hash( username().toUtf8() + ":" + realm + ":" + password().toUtf8(), QCryptographicHash::Md5); // Build response QMap<QByteArray, QByteArray> output; output["username"] = username().toUtf8(); if (!realm.isEmpty()) output["realm"] = realm; output["nonce"] = m_nonce; output["qop"] = "auth"; output["cnonce"] = m_cnonce; output["nc"] = m_nc; output["digest-uri"] = digestUri; output["response"] = calculateDigest("AUTHENTICATE", digestUri, m_secret, m_nonce, m_cnonce, m_nc); output["charset"] = "utf-8"; response = QXmppSaslDigestMd5::serializeMessage(output); m_step++; return true; } else if (m_step == 2) { const QMap<QByteArray, QByteArray> input = QXmppSaslDigestMd5::parseMessage(challenge); // check new challenge if (input.value("rspauth") != calculateDigest(QByteArray(), digestUri, m_secret, m_nonce, m_cnonce, m_nc)) { warning("QXmppSaslClientDigestMd5 : Invalid challenge on step 2"); return false; } response = QByteArray(); m_step++; return true; } else { warning("QXmppSaslClientDigestMd5 : Invalid step"); return false; } }
Handle<Value> DNSServiceResolve(Arguments const& args) { HandleScope scope; if (argumentCountMismatch(args, 8)) { return throwArgumentCountMismatchException(args, 8); } if ( ! ServiceRef::HasInstance(args[0])) { return throwTypeError("argument 1 must be a DNSServiceRef (sdRef)"); } ServiceRef * serviceRef = ObjectWrap::Unwrap<ServiceRef>(args[0]->ToObject()); if (serviceRef->IsInitialized()) { return throwError("DNSServiceRef is already initialized"); } if ( ! args[1]->IsInt32()) { return throwError("argument 2 must be an integer (DNSServiceFlags)"); } DNSServiceFlags flags = args[1]->ToInteger()->Int32Value(); if ( ! args[2]->IsInt32()) { return throwTypeError("argument 3 must be an integer (interfaceIndex)"); } uint32_t interfaceIndex = args[2]->ToInteger()->Int32Value(); if ( ! args[3]->IsString()) { return throwTypeError("argument 4 must be a string (name)"); } String::Utf8Value name(args[3]->ToString()); if ( ! args[4]->IsString()) { return throwTypeError("argument 5 must be a string (service type)"); } String::Utf8Value serviceType(args[4]->ToString()); if ( ! args[5]->IsString()) { return throwTypeError("argument 6 must be a string (domain)"); } String::Utf8Value domain(args[5]->ToString()); if ( ! args[6]->IsFunction()) { return throwTypeError("argument 7 must be a function (callBack)"); } serviceRef->SetCallback(Local<Function>::Cast(args[6])); if ( ! args[7]->IsNull() && ! args[7]->IsUndefined()) { serviceRef->SetContext(args[7]); } DNSServiceErrorType error = DNSServiceResolve( & serviceRef->GetServiceRef(), flags, interfaceIndex, *name, *serviceType, *domain, OnResolve, serviceRef); if (error != kDNSServiceErr_NoError) { return throwMdnsError("DNSServiceResolve()", error); } if ( ! serviceRef->SetSocketFlags()) { return throwError("Failed to set socket flags (O_NONBLOCK, FD_CLOEXEC)"); } return Undefined(); }
Handle<Value> DNSServiceRegister(Arguments const& args) { HandleScope scope; if (argumentCountMismatch(args, 11)) { return throwArgumentCountMismatchException(args, 11); } if ( ! ServiceRef::HasInstance(args[0])) { return throwTypeError("argument 1 must be a DNSServiceRef (sdRef)"); } ServiceRef * serviceRef = ObjectWrap::Unwrap<ServiceRef>(args[0]->ToObject()); if (serviceRef->IsInitialized()) { return throwError("DNSServiceRef is already initialized"); } if ( ! args[1]->IsInt32()) { return throwError("argument 2 must be an integer (DNSServiceFlags)"); } DNSServiceFlags flags = args[1]->ToInteger()->Int32Value(); if ( ! args[2]->IsInt32()) { return throwTypeError("argument 3 must be an integer (interfaceIndex)"); } uint32_t interfaceIndex = args[2]->ToInteger()->Int32Value(); bool has_name = false; if ( ! args[3]->IsNull() && ! args[3]->IsUndefined()) { if ( ! args[3]->IsString()) { return throwTypeError("argument 4 must be a string (name)"); } has_name = true; } String::Utf8Value name(args[3]); if ( ! args[4]->IsString()) { return throwTypeError("argument 5 must be a string (service type)"); } String::Utf8Value serviceType(args[4]->ToString()); bool has_domain = false; if ( ! args[5]->IsNull() && ! args[5]->IsUndefined()) { if ( ! args[5]->IsString()) { return throwTypeError("argument 6 must be a string (domain)"); } has_domain = true; } String::Utf8Value domain(args[5]); bool has_host = false; if ( ! args[6]->IsNull() && ! args[6]->IsUndefined()) { if ( ! args[6]->IsString()) { return throwTypeError("argument 7 must be a string (host)"); } has_host = true; } String::Utf8Value host(args[6]); if ( ! args[7]->IsInt32()) { return throwTypeError("argument 8 must be an integer (port)"); } int raw_port = args[7]->ToInteger()->Int32Value(); if (raw_port > std::numeric_limits<uint16_t>::max() || raw_port < 0) { return throwError("argument 8: port number is out of bounds."); } uint16_t port = static_cast<uint16_t>(raw_port); uint16_t txtLen(0); const void * txtRecord(NULL); if ( ! args[8]->IsNull() && ! args[8]->IsUndefined()) { if (Buffer::HasInstance(args[8])) { Local<Object> bufferObject = args[8]->ToObject(); txtRecord = Buffer::Data(bufferObject); txtLen = Buffer::Length(bufferObject); } else if (TxtRecordRef::HasInstance(args[8])) { TxtRecordRef * ref = ObjectWrap::Unwrap<TxtRecordRef>(args[8]->ToObject()); txtLen = TXTRecordGetLength( & ref->GetTxtRecordRef()); txtRecord = TXTRecordGetBytesPtr( & ref->GetTxtRecordRef()); } else { return throwTypeError("argument 9 must be a buffer or a dns_sd.TXTRecordRef"); } } if ( ! args[9]->IsNull() && ! args[9]->IsUndefined()) { if ( ! args[9]->IsFunction()) { return throwTypeError("argument 10 must be a function (callBack)"); } serviceRef->SetCallback(Local<Function>::Cast(args[9])); } if ( ! args[10]->IsNull() && ! args[10]->IsUndefined()) { serviceRef->SetContext(args[10]); } // eleven arguments ... srsly? DNSServiceErrorType error = DNSServiceRegister( & serviceRef->GetServiceRef(), flags, interfaceIndex, has_name ? * name : NULL, *serviceType, has_domain ? * domain : NULL, has_host ? * host : NULL, htons(port), txtLen, txtRecord, args[9]->IsFunction() ? OnServiceRegistered : NULL, serviceRef); if (error != kDNSServiceErr_NoError) { return throwMdnsError("DNSServiceRegister()", error); } if ( ! serviceRef->SetSocketFlags()) { return throwError("Failed to set socket flags (O_NONBLOCK, FD_CLOEXEC)"); } return Undefined(); }
int main(int argc, char* argv[]) { try { if(argc != 3) { //TODO: help message std::cout << "\n<< Help usage message >>\n" << std::endl; return SERVICE_PARAMETERS_ERROR; } std::string serviceType(argv[1]); std::transform(serviceType.begin(), serviceType.end(), serviceType.begin(), ::tolower); if(!checkServiceType(serviceType)) return UNKNOWN_SERVICE_TYPE; int listeningPort = std::stoi(argv[2]); try { terrama2::core::initializeTerraMA(); terrama2::core::registerFactories(); } catch(...) { return TERRAMA2_INITIALIZATION_ERROR; } auto& serviceManager = terrama2::core::ServiceManager::getInstance(); serviceManager.setServiceType(serviceType); serviceManager.setListeningPort(listeningPort); // service context // this is needed for calling the destructor of the service before finalizing terralib { // Must initialize the python interpreter before creating any thread. terrama2::services::analysis::core::initInterpreter(); QCoreApplication app(argc, argv); std::shared_ptr<terrama2::core::DataManager> dataManager; std::shared_ptr<terrama2::core::Service> service; std::shared_ptr<terrama2::core::ProcessLogger> logger; std::tie(dataManager, service, logger) = createService(serviceType); if(!service.get() || !dataManager.get()) return SERVICE_LOAD_ERROR; auto tcpManager = std::make_shared<terrama2::core::TcpManager>(dataManager, logger); if(!tcpManager->listen(QHostAddress::Any, serviceManager.listeningPort())) { std::cerr << QObject::tr("\nUnable to listen to port: ").toStdString() << serviceManager.listeningPort() << "\n" << std::endl; exit(TCP_SERVER_ERROR); } QObject::connect(&serviceManager, &terrama2::core::ServiceManager::listeningPortUpdated, tcpManager.get(), &terrama2::core::TcpManager::updateListeningPort); QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::startProcess, service.get(), &terrama2::core::Service::addToQueue); QObject::connect(&serviceManager, &terrama2::core::ServiceManager::numberOfThreadsUpdated, service.get(), &terrama2::core::Service::updateNumberOfThreads); QObject::connect(&serviceManager, &terrama2::core::ServiceManager::logConnectionInfoUpdated, logger.get(), &terrama2::core::ProcessLogger::setConnectionInfo); QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::stopSignal, service.get(), &terrama2::core::Service::stopService); QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::closeApp, &app, &QCoreApplication::quit); app.exec(); } try { terrama2::core::finalizeTerraMA(); //Service closed by load error if(!serviceManager.serviceLoaded()) return SERVICE_LOAD_ERROR; } catch(...) { return TERRAMA2_FINALIZATION_ERROR; } } catch(boost::exception& e) { TERRAMA2_LOG_ERROR() << boost::diagnostic_information(e); } catch(std::exception& e) { TERRAMA2_LOG_ERROR() << e.what(); } catch(...) { TERRAMA2_LOG_ERROR() << QObject::tr("\n\nUnkown Exception...\n"); } return 0; }
int main(int argc, char* argv[]) { try { std::string appName = boost::filesystem::basename(argv[0]); po::options_description desc("Allowed options"); desc.add_options() ("help,h", "show help message.") ("version,v", "Show TerraMA2 version.") ("service,s", po::value<std::string>()->required(), "Service to be started.\nValid options:\n\t- ANALYSIS\n\t- COLLECTOR\n\t- VIEW") ("port,p", po::value<int>()->required(), "Port the service will listen.") ; po::positional_options_description positionalOptions; positionalOptions.add("service", 1); positionalOptions.add("port", 1); po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(desc) .positional(positionalOptions).run(), vm); if (vm.count("help")) { std::cout << "usage: "+appName+" [--version] [--help] service port" << "\n"; std::cout << desc << std::endl; return 0; } if (vm.count("version")) { std::cout << "TerraMA2 " << TERRAMA2_VERSION_STRING << std::endl; return 0; } po::notify(vm); std::string serviceType(vm["service"].as<std::string>()); std::transform(serviceType.begin(), serviceType.end(), serviceType.begin(), ::tolower); if(!checkServiceType(serviceType)) return UNKNOWN_SERVICE_TYPE; int listeningPort = vm["port"].as<int>(); terrama2::core::TerraMA2Init terramaRaii(serviceType, listeningPort); terrama2::core::registerFactories(); auto& serviceManager = terrama2::core::ServiceManager::getInstance(); serviceManager.setServiceType(serviceType); serviceManager.setListeningPort(listeningPort); // service context // this is needed for calling the destructor of the service before finalizing terralib { TERRAMA2_LOG_INFO() << QObject::tr("Initializing TerraMA2 service..."); TERRAMA2_LOG_INFO() << QObject::tr("Starting %1 service.").arg(QString::fromStdString(serviceType)); // Must initialize the python interpreter before creating any thread. terrama2::services::analysis::core::PythonInterpreterInit pythonInterpreterInit; QCoreApplication app(argc, argv); // Changes in the initialization order may cause locale problems std::locale::global(std::locale::classic()); std::shared_ptr<terrama2::core::DataManager> dataManager; std::shared_ptr<terrama2::core::Service> service; std::shared_ptr<terrama2::core::ProcessLogger> logger; std::tie(dataManager, service, logger) = createService(serviceType); if(!service.get() || !dataManager.get() || !logger.get()) return SERVICE_LOAD_ERROR; auto tcpManager = std::make_shared<terrama2::core::TcpManager>(dataManager, logger); if(!tcpManager->listen(QHostAddress::Any, serviceManager.listeningPort())) { std::cerr << QObject::tr("\nUnable to listen to port: ").toStdString() << serviceManager.listeningPort() << "\n" << std::endl; exit(TCP_SERVER_ERROR); } QObject::connect(&serviceManager, &terrama2::core::ServiceManager::listeningPortUpdated, tcpManager.get(), &terrama2::core::TcpManager::updateListeningPort); QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::startProcess, service.get(), &terrama2::core::Service::addToQueue); QObject::connect(&serviceManager, &terrama2::core::ServiceManager::numberOfThreadsUpdated, service.get(), &terrama2::core::Service::updateNumberOfThreads); QObject::connect(&serviceManager, &terrama2::core::ServiceManager::logConnectionInfoUpdated, logger.get(), &terrama2::core::ProcessLogger::setConnectionInfo); QObject::connect(service.get(), &terrama2::core::Service::processFinishedSignal, tcpManager.get(), &terrama2::core::TcpManager::processFinishedSlot); QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::stopSignal, service.get(), &terrama2::core::Service::stopService); QObject::connect(service.get(), &terrama2::core::Service::serviceFinishedSignal, &app, &QCoreApplication::quit); app.exec(); } try { //Service closed by load error if(!serviceManager.serviceLoaded()) return SERVICE_LOAD_ERROR; } catch(...) { return TERRAMA2_FINALIZATION_ERROR; } } catch(boost::program_options::error& e) { std::cout << "Invalid options.See 'terrama2_service --help'\n" << std::endl; TERRAMA2_LOG_ERROR() << e.what(); } catch(boost::exception& e) { TERRAMA2_LOG_ERROR() << boost::diagnostic_information(e); } catch(std::exception& e) { TERRAMA2_LOG_ERROR() << e.what(); } catch(...) { TERRAMA2_LOG_ERROR() << QObject::tr("\n\nUnknown Exception...\n"); } return 0; }