fix merge conflict

This commit is contained in:
Dante Ruiz 2018-02-16 15:00:08 -08:00
commit aea517ddba
10 changed files with 110 additions and 80 deletions

View file

@ -1196,8 +1196,8 @@ bool DomainServerSettingsManager::handleAuthenticatedHTTPRequest(HTTPConnection
}
bool DomainServerSettingsManager::restoreSettingsFromObject(QJsonObject settingsToRestore, SettingsType settingsType) {
QJsonArray& filteredDescriptionArray = settingsType == DomainSettings
? _domainSettingsDescription : _contentSettingsDescription;
QJsonArray* filteredDescriptionArray = settingsType == DomainSettings
? &_domainSettingsDescription : &_contentSettingsDescription;
// grab a copy of the current config before restore, so that we can back out if something bad happens during
QVariantMap preRestoreConfig = _configMap.getConfig();
@ -1206,7 +1206,7 @@ bool DomainServerSettingsManager::restoreSettingsFromObject(QJsonObject settings
// enumerate through the settings in the description
// if we have one in the restore then use it, otherwise clear it from current settings
foreach(const QJsonValue& descriptionGroupValue, filteredDescriptionArray) {
foreach(const QJsonValue& descriptionGroupValue, *filteredDescriptionArray) {
QJsonObject descriptionGroupObject = descriptionGroupValue.toObject();
QString groupKey = descriptionGroupObject[DESCRIPTION_NAME_KEY].toString();
QJsonArray descriptionGroupSettings = descriptionGroupObject[DESCRIPTION_SETTINGS_KEY].toArray();
@ -1328,15 +1328,15 @@ QJsonObject DomainServerSettingsManager::settingsResponseObjectForType(const QSt
const QString AFFECTED_TYPES_JSON_KEY = "assignment-types";
// only enumerate the requested settings type (domain setting or content setting)
QJsonArray& filteredDescriptionArray = _descriptionArray;
QJsonArray* filteredDescriptionArray = &_descriptionArray;
if (includeDomainSettings && !includeContentSettings) {
filteredDescriptionArray = _domainSettingsDescription;
filteredDescriptionArray = &_domainSettingsDescription;
} else if (includeContentSettings && !includeDomainSettings) {
filteredDescriptionArray = _contentSettingsDescription;
filteredDescriptionArray = &_contentSettingsDescription;
}
// enumerate the groups in the potentially filtered object to find which settings to pass
foreach(const QJsonValue& groupValue, filteredDescriptionArray) {
foreach(const QJsonValue& groupValue, *filteredDescriptionArray) {
QJsonObject groupObject = groupValue.toObject();
QString groupKey = groupObject[DESCRIPTION_NAME_KEY].toString();
QJsonArray groupSettingsArray = groupObject[DESCRIPTION_SETTINGS_KEY].toArray();

View file

@ -2951,14 +2951,6 @@ void Application::setServersEnabled(bool serversEnabled) {
qDebug() << "QQQQ serversEnabled =" << serversEnabled;
if (_serversEnabled != serversEnabled) {
_serversEnabled = serversEnabled;
auto nodeList = DependencyManager::get<NodeList>();
nodeList->getDomainHandler().setAPIRefreshTimerEnabled(serversEnabled);
if (!_serversEnabled) {
nodeList->reset();
clearDomainOctreeDetails();
}
}
}
@ -2969,8 +2961,8 @@ bool Application::visitServerlessDomain(const QString& urlString) {
}
void Application::loadServerlessDomain(QUrl domainURL) {
resettingDomain();
domainChanged("");
// resettingDomain();
// domainChanged("");
importJSONFromURL(domainURL.toString());
}

View file

@ -120,16 +120,19 @@ QScriptValue WindowScriptingInterface::confirm(const QString& message) {
/// \param const QString& defaultText default text in the text box
/// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise.
QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
bool ok = false;
QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText, &ok);
return ok ? QScriptValue(result) : QScriptValue::NullValue;
QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText);
if (QScriptValue(result).equals("")) {
return QScriptValue::NullValue;
}
return QScriptValue(result);
}
/// Display a prompt with a text box
/// \param const QString& message message to display
/// \param const QString& defaultText default text in the text box
void WindowScriptingInterface::promptAsync(const QString& message, const QString& defaultText) {
ModalDialogListener* dlg = OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText);
bool ok = false;
ModalDialogListener* dlg = OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText, &ok);
connect(dlg, &ModalDialogListener::response, this, [=] (QVariant result) {
disconnect(dlg, &ModalDialogListener::response, this, nullptr);
emit promptTextChanged(result.toString());
@ -137,7 +140,7 @@ void WindowScriptingInterface::promptAsync(const QString& message, const QString
}
void WindowScriptingInterface::disconnectedFromDomain() {
emit domainChanged("");
emit domainChanged("", QUrl());
}
CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) {

View file

@ -547,7 +547,7 @@ signals:
*
* Window.domainChanged.connect(onDomainChanged);
*/
void domainChanged(const QString& domain);
void domainChanged(const QString& domain, const QUrl& serverlessDomainURL);
/**jsdoc
* Triggered when you try to navigate to a *.json, *.svo, or *.svo.json URL in a Web browser within Interface.

View file

@ -219,7 +219,7 @@ void Avatar::updateAvatarEntities() {
return;
}
if (getID() == QUuid()) {
if (getID() == QUuid() || getID() == AVATAR_SELF_ID) {
return; // wait until MyAvatar gets an ID before doing this.
}

View file

@ -58,24 +58,33 @@ bool AddressManager::isConnected() {
QUrl AddressManager::currentAddress(bool domainOnly) const {
QUrl hifiURL;
hifiURL.setScheme(HIFI_URL_SCHEME);
hifiURL.setHost(_host);
if (_port != 0 && _port != DEFAULT_DOMAIN_SERVER_PORT) {
hifiURL.setPort(_port);
if (!_filebasedDomainURL.isEmpty()) {
hifiURL = _filebasedDomainURL;
} else {
hifiURL.setScheme(HIFI_URL_SCHEME);
hifiURL.setHost(_host);
if (_port != 0 && _port != DEFAULT_DOMAIN_SERVER_PORT) {
hifiURL.setPort(_port);
}
}
if (!domainOnly) {
if (!domainOnly && hifiURL.scheme() == HIFI_URL_SCHEME) {
hifiURL.setPath(currentPath());
}
qDebug() << "QQQQ currentAddress --> " << hifiURL.toString();
return hifiURL;
}
QUrl AddressManager::currentFacingAddress() const {
auto hifiURL = currentAddress();
hifiURL.setPath(currentFacingPath());
if (hifiURL.scheme() == HIFI_URL_SCHEME) {
hifiURL.setPath(currentFacingPath());
}
qDebug() << "QQQQ currentFacingAddress --> " << hifiURL.toString();
return hifiURL;
}
@ -91,16 +100,21 @@ QUrl AddressManager::currentShareableAddress(bool domainOnly) const {
hifiURL.setPath(currentPath());
}
qDebug() << "QQQQ currentShareableAddress --> " << hifiURL.toString();
return hifiURL;
} else {
qDebug() << "QQQQ currentShareableAddress --> " << currentAddress(domainOnly).toString();
return currentAddress(domainOnly);
}
}
QUrl AddressManager::currentFacingShareableAddress() const {
auto hifiURL = currentShareableAddress();
hifiURL.setPath(currentFacingPath());
if (hifiURL.scheme() == HIFI_URL_SCHEME) {
hifiURL.setPath(currentFacingPath());
}
qDebug() << "QQQQ currentFacingShareableAddress --> " << hifiURL.toString();
return hifiURL;
}
@ -294,11 +308,14 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
return true;
} else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") {
QUrl url = lookupUrl;
qDebug() << "QQQQ file or http before serverless domain" << lookupUrl.toString();
_previousLookup.clear();
QUrl domainUrl = lookupUrl;
const QString path = PathUtils::expandToAppAbsolutePath(lookupUrl.path());
url.setPath(path);
domainUrl.setPath(path);
emit setServersEnabled(false);
emit loadServerlessDomain(url);
setDomainInfo(domainUrl, QString(), 0, trigger);
emit loadServerlessDomain(domainUrl);
emit lookupResultsFinished();
return true;
}
@ -389,6 +406,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
QVariantMap domainObject = rootMap[LOCATION_API_DOMAIN_KEY].toMap();
if (!domainObject.isEmpty()) {
// XXX serverless domain URL ?
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";
@ -408,7 +426,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
<< "on" << domainPort;
emit possibleDomainChangeRequired(domainHostname, domainPort, domainID);
emit possibleDomainChangeRequired(QUrl(), domainHostname, domainPort, domainID);
} else {
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
@ -580,7 +598,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
}
emit lookupResultsFinished();
hostChanged = setDomainInfo(domainIPString, domainPort, trigger);
hostChanged = setDomainInfo(QUrl(), domainIPString, domainPort, trigger);
return true;
}
@ -597,7 +615,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
}
emit lookupResultsFinished();
hostChanged = setDomainInfo(domainHostname, domainPort, trigger);
hostChanged = setDomainInfo(QUrl(), domainHostname, domainPort, trigger);
return true;
}
@ -741,18 +759,24 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
return false;
}
bool AddressManager::setDomainInfo(const QString& hostname, quint16 port, LookupTrigger trigger) {
bool AddressManager::setDomainInfo(const QUrl& serverlessDomainURL,
const QString& hostname, quint16 port, LookupTrigger trigger) {
bool hostChanged = setHost(hostname, trigger, port);
// clear any current place information
_rootPlaceID = QUuid();
_placeName.clear();
_filebasedDomainURL = serverlessDomainURL;
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
if (!serverlessDomainURL.isEmpty()) {
qCDebug(networking) << "Possible domain change required to serverless domain: " << serverlessDomainURL;
} else {
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
}
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);
emit possibleDomainChangeRequired(hostname, port, QUuid());
emit possibleDomainChangeRequired(serverlessDomainURL, hostname, port, QUuid());
return hostChanged;
}

View file

@ -311,13 +311,15 @@ signals:
/**jsdoc
* Triggered when a request is made to go to an IP address.
* @function location.possibleDomainChangeRequired
* @param {string} serverlessDomainURL - URL for a file-based domain
* @param {string} hostName - The name of the domain to go do.
* @param {number} port - The integer number of the network port to connect to.
* @param {Uuid} domainID - The UUID of the domain to go to.
* @returns {Signal}
*/
// No example because this function isn't typically used in scripts.
void possibleDomainChangeRequired(const QString& newHostname, quint16 newPort, const QUuid& domainID);
void possibleDomainChangeRequired(const QUrl& serverlessDomainURL,
const QString& newHostname, quint16 newPort, const QUuid& domainID);
/**jsdoc
* Triggered when a request is made to go to a named domain or user.
@ -432,7 +434,7 @@ private:
// Set host and port, and return `true` if it was changed.
bool setHost(const QString& host, LookupTrigger trigger, quint16 port = 0);
bool setDomainInfo(const QString& hostname, quint16 port, LookupTrigger trigger);
bool setDomainInfo(const QUrl& serverlessDomainURL, const QString& hostname, quint16 port, LookupTrigger trigger);
const JSONCallbackParameters& apiCallbackParameters();
@ -453,6 +455,7 @@ private:
QString _host;
quint16 _port;
QString _placeName;
QUrl _filebasedDomainURL; // for serverless domains
QUuid _rootPlaceID;
PositionGetter _positionGetter;
OrientationGetter _orientationGetter;
@ -464,7 +467,7 @@ private:
quint64 _lastBackPush = 0;
QString _newHostLookupPath;
QUrl _previousLookup;
};

View file

@ -48,33 +48,23 @@ DomainHandler::DomainHandler(QObject* parent) :
const int API_REFRESH_TIMEOUT_MSEC = 2500;
_apiRefreshTimer.setInterval(API_REFRESH_TIMEOUT_MSEC); // 2.5s, Qt::CoarseTimer acceptable
connect(&_apiRefreshTimer, &QTimer::timeout, [this] {
if (_apiRefreshTimerEnabled) {
auto addressManager = DependencyManager::get<AddressManager>();
if (addressManager) {
addressManager->refreshPreviousLookup();
}
}
});
auto addressManager = DependencyManager::get<AddressManager>();
connect(&_apiRefreshTimer, &QTimer::timeout, addressManager.data(), &AddressManager::refreshPreviousLookup);
// stop the refresh timer if we connect to a domain
connect(this, &DomainHandler::connectedToDomain, &_apiRefreshTimer, &QTimer::stop);
}
void DomainHandler::setAPIRefreshTimerEnabled(bool enabled) {
_apiRefreshTimerEnabled = enabled;
}
void DomainHandler::disconnect() {
// if we're currently connected to a domain, send a disconnect packet on our way out
if (_isConnected) {
sendDisconnectPacket();
}
// clear member variables that hold the connection state to a domain
_uuid = QUuid();
_connectionToken = QUuid();
_icePeer.reset();
if (requiresICE()) {
@ -88,10 +78,10 @@ void DomainHandler::disconnect() {
void DomainHandler::sendDisconnectPacket() {
// The DomainDisconnect packet is not verified - we're relying on the eventual addition of DTLS to the
// domain-server connection to stop greifing here
// construct the disconnect packet once (an empty packet but sourced with our current session UUID)
static auto disconnectPacket = NLPacket::create(PacketType::DomainDisconnectRequest, 0);
// send the disconnect packet to the current domain server
auto nodeList = DependencyManager::get<NodeList>();
nodeList->sendUnreliablePacket(*disconnectPacket, _sockAddr);
@ -104,7 +94,7 @@ void DomainHandler::clearSettings() {
void DomainHandler::softReset() {
qCDebug(networking) << "Resetting current domain connection information.";
disconnect();
clearSettings();
_connectionDenialsSinceKeypairRegen = 0;
@ -127,6 +117,7 @@ void DomainHandler::hardReset() {
_iceServerSockAddr = HifiSockAddr();
_hostname = QString();
_sockAddr.clear();
_serverlessDomainURL = QUrl();
_domainConnectionRefusals.clear();
@ -150,6 +141,7 @@ void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hos
// some callers may pass a hostname, this is not to be used for lookup but for DTLS certificate verification
_hostname = hostname;
_serverlessDomainURL = QUrl();
}
void DomainHandler::setUUID(const QUuid& uuid) {
@ -159,27 +151,35 @@ void DomainHandler::setUUID(const QUuid& uuid) {
}
}
void DomainHandler::setSocketAndID(const QString& hostname, quint16 port, const QUuid& domainID) {
void DomainHandler::setSocketAndID(const QUrl& serverlessDomainURL,
const QString& hostname, quint16 port, const QUuid& domainID) {
_pendingDomainID = domainID;
if (hostname != _hostname || _sockAddr.getPort() != port) {
if (serverlessDomainURL != _serverlessDomainURL || hostname != _hostname || _sockAddr.getPort() != port) {
// re-set the domain info so that auth information is reloaded
hardReset();
if (serverlessDomainURL != _serverlessDomainURL) {
_serverlessDomainURL = serverlessDomainURL;
}
if (hostname != _hostname) {
// set the new hostname
_hostname = hostname;
qCDebug(networking) << "Updated domain hostname to" << _hostname;
// re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
qCDebug(networking, "Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
if (!_hostname.isEmpty()) {
// re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
qCDebug(networking, "Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainHostname);
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(
LimitedNodeList::ConnectionStep::SetDomainHostname);
UserActivityLogger::getInstance().changedDomain(_hostname);
UserActivityLogger::getInstance().changedDomain(_hostname);
}
emit hostnameChanged(_hostname);
}
@ -197,10 +197,10 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
if (_iceServerSockAddr.getAddress().toString() != iceServerHostname || id != _pendingDomainID) {
// re-set the domain info to connect to new domain
hardReset();
// refresh our ICE client UUID to something new
_iceClientID = QUuid::createUuid();
_pendingDomainID = id;
HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr;
@ -227,6 +227,7 @@ void DomainHandler::activateICELocalSocket() {
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
_sockAddr = _icePeer.getLocalSocket();
_hostname = _sockAddr.getAddress().toString();
_serverlessDomainURL = QUrl();
emit completedSocketDiscovery();
}
@ -234,6 +235,7 @@ void DomainHandler::activateICEPublicSocket() {
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
_sockAddr = _icePeer.getPublicSocket();
_hostname = _sockAddr.getAddress().toString();
_serverlessDomainURL = QUrl();
emit completedSocketDiscovery();
}
@ -271,10 +273,12 @@ void DomainHandler::setIsConnected(bool isConnected) {
_isConnected = isConnected;
if (_isConnected) {
emit connectedToDomain(_hostname);
emit connectedToDomain(_hostname, _serverlessDomainURL);
// we've connected to new domain - time to ask it for global settings
requestDomainSettings();
if (!_hostname.isEmpty()) {
// we've connected to new domain - time to ask it for global settings
requestDomainSettings();
}
} else {
emit disconnectedFromDomain();

View file

@ -141,7 +141,8 @@ public:
void setAPIRefreshTimerEnabled(bool enabled);
public slots:
void setSocketAndID(const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT, const QUuid& id = QUuid());
void setSocketAndID(const QUrl& serverlessDomainURL,
const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT, const QUuid& id = QUuid());
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
void processSettingsPacketList(QSharedPointer<ReceivedMessage> packetList);
@ -162,7 +163,7 @@ signals:
void completedSocketDiscovery();
void resetting();
void connectedToDomain(const QString& hostname);
void connectedToDomain(const QString& hostname, const QUrl& serverlessDomainURL);
void disconnectedFromDomain();
void iceSocketAndIDReceived();
@ -181,6 +182,7 @@ private:
void hardReset();
QUuid _uuid;
QUrl _serverlessDomainURL;
QString _hostname;
HifiSockAddr _sockAddr;
QUuid _assignmentUUID;
@ -200,7 +202,6 @@ private:
int _checkInPacketsSinceLastReply { 0 };
QTimer _apiRefreshTimer;
bool _apiRefreshTimerEnabled { true };
};
#endif // hifi_DomainHandler_h

View file

@ -340,10 +340,11 @@ class InputDialogListener : public ModalDialogListener {
return;
}
connect(_dialog, SIGNAL(selected(QVariant)), this, SLOT(onSelected(const QVariant&)));
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelected()));
}
private slots:
void onSelected(const QVariant& result) {
void onSelected(const QVariant& result = "") {
_result = result;
auto offscreenUi = DependencyManager::get<OffscreenUi>();
emit response(_result);
@ -698,10 +699,11 @@ class FileDialogListener : public ModalDialogListener {
return;
}
connect(_dialog, SIGNAL(selectedFile(QVariant)), this, SLOT(onSelectedFile(QVariant)));
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelectedFile()));
}
private slots:
void onSelectedFile(QVariant file) {
void onSelectedFile(QVariant file = "") {
_result = file.toUrl().toLocalFile();
_finished = true;
auto offscreenUi = DependencyManager::get<OffscreenUi>();
@ -947,10 +949,11 @@ class AssetDialogListener : public ModalDialogListener {
return;
}
connect(_dialog, SIGNAL(selectedAsset(QVariant)), this, SLOT(onSelectedAsset(QVariant)));
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelectedAsset()));
}
private slots:
void onSelectedAsset(QVariant asset) {
void onSelectedAsset(QVariant asset = "") {
_result = asset;
auto offscreenUi = DependencyManager::get<OffscreenUi>();
emit response(_result);