bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
    if (lookupUrl.scheme() == HIFI_URL_SCHEME) {

        qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();

        DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::LookupAddress);

        // there are 4 possible lookup strings

        // 1. global place name (name of domain or place) - example: sanfrancisco
        // 2. user name (prepended with @) - example: @philip
        // 3. location string (posX,posY,posZ/eulerX,eulerY,eulerZ)
        // 4. domain network address (IP or dns resolvable hostname)

        // use our regex'ed helpers to figure out what we're supposed to do with this
        if (!handleUsername(lookupUrl.authority())) {
            // we're assuming this is either a network address or global place name
            // check if it is a network address first
            bool hostChanged;
            if (handleNetworkAddress(lookupUrl.host()
                                      + (lookupUrl.port() == -1 ? "" : ":" + QString::number(lookupUrl.port())), trigger, hostChanged)) {

                // If the host changed then we have already saved to history
                if (hostChanged) {
                    trigger = Internal;
                }

                // if we were not passed a path, use the index path
                auto path = lookupUrl.path();
                if (path.isEmpty()) {
                    path = INDEX_PATH;
                }

                // we may have a path that defines a relative viewpoint - if so we should jump to that now
                handlePath(path, trigger);
            } else if (handleDomainID(lookupUrl.host())){
                // no place name - this is probably a domain ID
                // try to look up the domain ID on the metaverse API
                attemptDomainIDLookup(lookupUrl.host(), lookupUrl.path(), trigger);
            } else {
                // wasn't an address - lookup the place name
                // we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after
                attemptPlaceNameLookup(lookupUrl.host(), lookupUrl.path(), trigger);
            }
        }

        return true;

    } else if (lookupUrl.toString().startsWith('/')) {
        qCDebug(networking) << "Going to relative path" << lookupUrl.path();

        // if this is a relative path then handle it as a relative viewpoint
        handlePath(lookupUrl.path(), trigger, true);
        emit lookupResultsFinished();
        return true;
    }

    return false;
}
Exemple #2
0
void ControlSlider::paintEvent(QPaintEvent * /* event */)
{
	QPainter painter(this);
	painter.setRenderHint(QPainter::Antialiasing);

	/* draw background */
	QBrush brush(backgroundGradient());
	painter.setBrush(brush);
	painter.setPen(Qt::NoPen);
	painter.drawPath(backgroundPath());

	/* draw handle */
	brush = handleGradient();
	painter.setBrush(brush);
	painter.setPen(Qt::NoPen);
	painter.drawPath(handlePath());
}
Exemple #3
0
void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const QNetworkReply& reply) {

    const QString DATA_OBJECT_PLACE_KEY = "place";
    const QString DATA_OBJECT_USER_LOCATION_KEY = "location";

    QVariantMap locationMap;
    if (dataObject.contains(DATA_OBJECT_PLACE_KEY)) {
        locationMap = dataObject[DATA_OBJECT_PLACE_KEY].toMap();
    } else if (dataObject.contains(DATA_OBJECT_DOMAIN_KEY)) {
        locationMap = dataObject;
    } else {
        locationMap = dataObject[DATA_OBJECT_USER_LOCATION_KEY].toMap();
    }

    if (!locationMap.isEmpty()) {
        const QString LOCATION_API_ROOT_KEY = "root";
        const QString LOCATION_API_DOMAIN_KEY = "domain";
        const QString LOCATION_API_ONLINE_KEY = "online";

        if (!locationMap.contains(LOCATION_API_ONLINE_KEY)
            || locationMap[LOCATION_API_ONLINE_KEY].toBool()) {

            QVariantMap rootMap = locationMap[LOCATION_API_ROOT_KEY].toMap();
            if (rootMap.isEmpty()) {
                rootMap = locationMap;
            }

            QVariantMap domainObject = rootMap[LOCATION_API_DOMAIN_KEY].toMap();

            if (!domainObject.isEmpty()) {
                const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address";
                const QString DOMAIN_NETWORK_PORT_KEY = "network_port";
                const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";

                DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);

                const QString DOMAIN_ID_KEY = "id";
                QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
                QUuid domainID(domainIDString);

                if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) {
                    QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString();

                    quint16 domainPort = domainObject.contains(DOMAIN_NETWORK_PORT_KEY)
                        ? domainObject[DOMAIN_NETWORK_PORT_KEY].toUInt()
                        : DEFAULT_DOMAIN_SERVER_PORT;

                    qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
                        << "on" << domainPort;
                    emit possibleDomainChangeRequired(domainHostname, domainPort);
                } else {
                    QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();

                    qCDebug(networking) << "Possible domain change required to connect to domain with ID" << domainID
                        << "via ice-server at" << iceServerAddress;

                    emit possibleDomainChangeRequiredViaICEForID(iceServerAddress, domainID);
                }

                LookupTrigger trigger = (LookupTrigger) reply.property(LOOKUP_TRIGGER_KEY).toInt();

                // set our current root place id to the ID that came back
                const QString PLACE_ID_KEY = "id";
                _rootPlaceID = rootMap[PLACE_ID_KEY].toUuid();

                // set our current root place name to the name that came back
                const QString PLACE_NAME_KEY = "name";
                QString placeName = rootMap[PLACE_NAME_KEY].toString();
                if (!placeName.isEmpty()) {
                    setHost(placeName, trigger);
                } else {
                    setHost(domainIDString, trigger);
                }

                // check if we had a path to override the path returned
                QString overridePath = reply.property(OVERRIDE_PATH_KEY).toString();

                if (!overridePath.isEmpty()) {
                    handlePath(overridePath, trigger);
                } else {
                    // take the path that came back
                    const QString PLACE_PATH_KEY = "path";
                    QString returnedPath = locationMap[PLACE_PATH_KEY].toString();

                    bool shouldFaceViewpoint = locationMap.contains(LOCATION_API_ONLINE_KEY);

                    if (!returnedPath.isEmpty()) {
                        if (shouldFaceViewpoint) {
                            // try to parse this returned path as a viewpoint, that's the only thing it could be for now
                            if (!handleViewpoint(returnedPath, shouldFaceViewpoint)) {
                                qCDebug(networking) << "Received a location path that was could not be handled as a viewpoint -"
                                    << returnedPath;
                            }
                        } else {
                            handlePath(returnedPath, trigger);
                        }
                    } else {
                        // we're going to hit the index path, set that as the _newHostLookupPath
                        _newHostLookupPath = INDEX_PATH;

                        // we didn't override the path or get one back - ask the DS for the viewpoint of its index path
                        // which we will jump to if it exists
                        emit pathChangeRequired(INDEX_PATH);
                    }
                }

            } else {
                qCDebug(networking) << "Received an address manager API response with no domain key. Cannot parse.";
                qCDebug(networking) << locationMap;
            }
        } else {
            // we've been told that this result exists but is offline, emit our signal so the application can handle
            emit lookupResultIsOffline();
        }
    } else {
        qCDebug(networking) << "Received an address manager API response with no location key or place key. Cannot parse.";
        qCDebug(networking) << locationMap;
    }
}
Exemple #4
0
void StereoNode::reconfig(stereoConfig &config, uint32_t level)
{
  force_streaming_ = config.force_streaming;
  handlePath(config.config_path);

  const FlashMode flash_active_mode = config.flash_polarity ? FLASH_FREERUN_ACTIVE_HI : FLASH_FREERUN_ACTIVE_LO;

  if (trigger_mode_ != config.trigger) {
    stopCamera();
    TriggerMode l_trigger, r_trigger;
    FlashMode l_flash = FLASH_OFF;
    FlashMode r_flash = FLASH_OFF;
    switch (config.trigger) {
      case stereo_TGR_SOFTWARE:
      case stereo_TGR_HARDWARE_RISING:
        l_trigger = r_trigger = TRIGGER_LO_HI;
        break;
      case stereo_TGR_HARDWARE_FALLING:
        l_trigger = r_trigger = TRIGGER_HI_LO;
        break;
      case stereo_TGR_L_MASTER_R_RISING:
        l_trigger = TRIGGER_OFF;
        r_trigger = TRIGGER_LO_HI;
        l_flash = flash_active_mode;
        break;
      case stereo_TGR_L_MASTER_R_FALLING:
        l_trigger = TRIGGER_OFF;
        r_trigger = TRIGGER_HI_LO;
        l_flash = flash_active_mode;
        break;
      case stereo_TGR_R_MASTER_L_RISING:
        l_trigger = TRIGGER_LO_HI;
        r_trigger = TRIGGER_OFF;
        r_flash = flash_active_mode;
        break;
      case stereo_TGR_R_MASTER_L_FALLING:
        l_trigger = TRIGGER_HI_LO;
        r_trigger = TRIGGER_OFF;
        r_flash = flash_active_mode;
        break;
      case stereo_TGR_AUTO:
      default:
        config.trigger = stereo_TGR_AUTO;
        l_trigger = r_trigger = TRIGGER_OFF;
        break;
    }
    if (!(l_cam_.setTriggerMode(l_trigger) && r_cam_.setTriggerMode(r_trigger))) {
      ROS_ERROR("Failed to configure triggers");
      l_cam_.setTriggerMode(TRIGGER_OFF);
      r_cam_.setTriggerMode(TRIGGER_OFF);
      config.trigger = stereo_TGR_AUTO;
      l_cam_.setFlash(FLASH_OFF);
      r_cam_.setFlash(FLASH_OFF);
    } else {
      l_cam_.setFlash(l_flash, config.flash_delay, config.flash_duration);
      r_cam_.setFlash(r_flash, config.flash_delay, config.flash_duration);
    }
  }

  // Latch Auto Parameters
  if (auto_gain_ && !config.auto_gain) {
    config.gain = l_cam_.getHardwareGain();
  }
  auto_gain_ = config.auto_gain;
  if (auto_exposure_ && !config.auto_exposure) {
    config.exposure_time = l_cam_.getExposure();
  }
  auto_exposure_ = config.auto_exposure;

  // Pixel Clock
  if (l_cam_.getPixelClock() != config.l_pixel_clock) {
    l_cam_.setPixelClock(&config.l_pixel_clock);
  }
  if (r_cam_.getPixelClock() != config.r_pixel_clock) {
    r_cam_.setPixelClock(&config.r_pixel_clock);
  }

  reconfigCam(config, level, l_cam_);
  reconfigCam(config, level, r_cam_);

  trigger_mode_ = config.trigger;
  if (trigger_mode_ == stereo_TGR_SOFTWARE) {
    timer_force_trigger_.setPeriod(ros::Duration(1 / config.frame_rate));
  }

  if (zoom_ != config.zoom) {
    zoom_ = config.zoom;
    loadIntrinsics(l_cam_, l_msg_camera_info_);
    loadIntrinsics(r_cam_, r_msg_camera_info_);
  }

  l_msg_camera_info_.header.frame_id = config.l_frame_id;
  r_msg_camera_info_.header.frame_id = config.r_frame_id;
  configured_ = true;
}