qint32 HConnectionManagerSinkService::prepareForConnection( const HProtocolInfo& remoteProtocolInfo, const HConnectionManagerId& peerConnectionManager, qint32 peerConnectionId, HConnectionManagerInfo::Direction direction, HPrepareForConnectionResult* result) { Q_ASSERT(result); if (!actions().value("PrepareForConnection")) { return UpnpOptionalActionNotImplemented; } if (direction != HConnectionManagerInfo::DirectionInput) { return HConnectionManagerInfo::IncompatibleDirections; } if (remoteProtocolInfo.protocol().compare("http-get", Qt::CaseInsensitive) && remoteProtocolInfo.protocol() != "*") { return HConnectionManagerInfo::IncompatibleProtocolInfo; } if (!isMimetypeValid( remoteProtocolInfo.contentFormat(), sinkProtocolInfo())) { return HConnectionManagerInfo::IncompatibleProtocolInfo; } qint32 connectionId = nextId(); qint32 avTransportId, rcsId; qint32 errCode = m_owner->prepareForConnection( remoteProtocolInfo.contentFormat(), connectionId, &avTransportId, &rcsId); if (errCode != UpnpSuccess) { return errCode; } HConnectionInfo connectionInfo( connectionId, avTransportId, rcsId, remoteProtocolInfo, peerConnectionManager, peerConnectionId, HConnectionManagerInfo::DirectionInput, HConnectionManagerInfo::StatusOk); result->setAvTransportId(avTransportId); result->setConnectionId(connectionId); result->setRcsId(rcsId); addConnection(connectionInfo); return UpnpSuccess; }
ITransportConnectionInfoPtr createTransportInfo(const std::int32_t& accessPointId , const std::int32_t& protocolId , const std::int32_t& protocolVersion , const std::string& encodedConnectionData) { auto buffer = Botan::base64_decode(encodedConnectionData); ITransportConnectionInfoPtr connectionInfo( new GenericTransportInfo(ServerType::BOOTSTRAP , accessPointId , TransportProtocolId(protocolId, protocolVersion) , std::vector<std::uint8_t>(buffer.begin(), buffer.end()))); return connectionInfo; }
QString QgsSpatiaLiteSourceSelect::layerURI( const QModelIndex &index ) { QString tableName = mTableModel.itemFromIndex( index.sibling( index.row(), 0 ) )->text(); QString geomColumnName = mTableModel.itemFromIndex( index.sibling( index.row(), 2 ) )->text(); QString sql = mTableModel.itemFromIndex( index.sibling( index.row(), 3 ) )->text(); if ( geomColumnName.contains( " AS " ) ) { int a = geomColumnName.indexOf( " AS " ); QString typeName = geomColumnName.mid( a + 4 ); //only the type name geomColumnName = geomColumnName.left( a ); //only the geom column name QString geomFilter; if ( typeName == "POINT" ) { geomFilter = QString( "geometrytype(\"%1\") IN ('POINT','MULTIPOINT')" ).arg( geomColumnName ); } else if ( typeName == "LINESTRING" ) { geomFilter = QString( "geometrytype(\"%1\") IN ('LINESTRING','MULTILINESTRING')" ).arg( geomColumnName ); } else if ( typeName == "POLYGON" ) { geomFilter = QString( "geometrytype(\"%1\") IN ('POLYGON','MULTIPOLYGON')" ).arg( geomColumnName ); } if ( !geomFilter.isEmpty() && !sql.contains( geomFilter ) ) { if ( !sql.isEmpty() ) { sql += " AND "; } sql += geomFilter; } } QgsDataSourceURI uri( connectionInfo() ); uri.setDataSource( "", tableName, geomColumnName, sql, "" ); return uri.uri(); }
void BootstrapManager::onServerListUpdated(const std::vector<ProtocolMetaData>& operationsServers) { if (operationsServers.empty()) { KAA_LOG_WARN("Received empty operations server list"); FailoverStrategyDecision decision = failoverStrategy_->onFailover(Failover::NO_OPERATION_SERVERS); switch (decision.getAction()) { case FailoverStrategyAction::NOOP: KAA_LOG_WARN("No operation is performed according to failover strategy decision."); break; case FailoverStrategyAction::RETRY: { std::size_t period = decision.getRetryPeriod(); KAA_LOG_WARN(boost::format("Attempt to receive operations server list will be made in %1% secs " "according to failover strategy decision.") % period); retryTimer_.stop(); retryTimer_.start(period, [&] { receiveOperationsServerList(); }); break; } case FailoverStrategyAction::STOP_APP: KAA_LOG_WARN("Stopping application according to failover strategy decision!"); exit(EXIT_FAILURE); break; } return; } KAA_R_MUTEX_UNIQUE_DECLARE(lock, guard_); KAA_LOG_INFO(boost::format("Received %1% new operations servers") % operationsServers.size()); lastOperationsServers_.clear(); operationServers_.clear(); for (const auto& serverMetaData : operationsServers) { ITransportConnectionInfoPtr connectionInfo( new GenericTransportInfo(ServerType::OPERATIONS, serverMetaData)); auto& servers = operationServers_[serverMetaData.protocolVersionInfo]; servers.push_back(connectionInfo); } for (auto& transportSpecificServers : operationServers_) { std::shuffle (transportSpecificServers.second.begin() , transportSpecificServers.second.end() , std::default_random_engine(std::chrono::high_resolution_clock::now().time_since_epoch().count())); lastOperationsServers_[transportSpecificServers.first] = transportSpecificServers.second.begin(); } if (serverToApply) { auto servers = getOPSByAccessPointId(*serverToApply); if (!servers.empty()) { KAA_LOG_DEBUG(boost::format("Found %1% servers by access point id %2%") % servers.size() % *serverToApply); serverToApply.reset(); notifyChannelManangerAboutServer(servers); } } else { for (const auto& transportSpecificServers : operationServers_) { channelManager_->onTransportConnectionInfoUpdated(transportSpecificServers.second.front()); } } }
QString QgsDataSourceURI::uri() const { QString theUri = connectionInfo(); if ( !mKeyColumn.isEmpty() ) { theUri += QString( " key='%1'" ).arg( escape( mKeyColumn ) ); } if ( mUseEstimatedMetadata ) { theUri += QString( " estimatedmetadata=true" ); } if ( !mSrid.isEmpty() ) { theUri += QString( " srid=%1" ).arg( mSrid ); } if ( mWkbType != QGis::WKBUnknown && mWkbType != QGis::WKBNoGeometry ) { theUri += " type="; switch( mWkbType ) { case QGis::WKBPoint: theUri += "POINT"; break; case QGis::WKBLineString: theUri += "LINESTRING"; break; case QGis::WKBPolygon: theUri += "POLYGON"; break; case QGis::WKBMultiPoint: theUri += "MULTIPOINT"; break; case QGis::WKBMultiLineString: theUri += "MULTILINESTRING"; break; case QGis::WKBMultiPolygon: theUri += "MULTIPOLYGON"; break; case QGis::WKBPoint25D: theUri += "POINTM"; break; case QGis::WKBLineString25D: theUri += "LINESTRINGM"; break; case QGis::WKBPolygon25D: theUri += "POLYGONM"; break; case QGis::WKBMultiPoint25D: theUri += "MULTIPOINTM"; break; case QGis::WKBMultiLineString25D: theUri += "MULTILINESTRINGM"; break; case QGis::WKBMultiPolygon25D: theUri += "MULTIPOLYGONM"; break; case QGis::WKBUnknown: case QGis::WKBNoGeometry: break; } } if ( mSelectAtIdDisabled ) { theUri += QString( " selectatid=false" ); } theUri += QString( " table=%1%2 sql=%3" ) .arg( quotedTablename() ) .arg( mGeometryColumn.isNull() ? QString() : QString( " (%1)" ).arg( mGeometryColumn ) ) .arg( mSql ); return theUri; }