mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
some url handling repairs, move existing error reply handlers to new format
This commit is contained in:
parent
7896119228
commit
1f2020d169
9 changed files with 37 additions and 65 deletions
|
@ -358,9 +358,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
Particle::setVoxelEditPacketSender(&_voxelEditSender);
|
||||
Particle::setParticleEditPacketSender(&_particleEditSender);
|
||||
|
||||
// when -url in command line, teleport to location
|
||||
urlGoTo(argc, constArgv);
|
||||
|
||||
// For now we're going to set the PPS for outbound packets to be super high, this is
|
||||
// probably not the right long term solution. But for now, we're going to do this to
|
||||
// allow you to move a particle around in your hand
|
||||
|
@ -405,13 +402,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
connect(_window, &MainWindow::windowGeometryChanged,
|
||||
_runningScriptsWidget, &RunningScriptsWidget::setBoundary);
|
||||
|
||||
AddressManager& addressManager = AddressManager::getInstance();
|
||||
|
||||
// connect to the domainChangeRequired signal on AddressManager
|
||||
connect(&AddressManager::getInstance(), &AddressManager::possibleDomainChangeRequired,
|
||||
connect(&addressManager, &AddressManager::possibleDomainChangeRequired,
|
||||
this, &Application::changeDomainHostname);
|
||||
|
||||
//When -url in command line, teleport to location
|
||||
urlGoTo(argc, constArgv);
|
||||
// when -url in command line, teleport to location
|
||||
addressManager.handleUrl(QUrl(getCmdOption(argc, constArgv, "-url")));
|
||||
|
||||
// call the OAuthWebviewHandler static getter so that its instance lives in our thread
|
||||
OAuthWebViewHandler::getInstance();
|
||||
|
@ -1066,10 +1065,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_Equal:
|
||||
_myAvatar->resetSize();
|
||||
break;
|
||||
|
||||
case Qt::Key_At:
|
||||
// Menu::getInstance()->goTo();
|
||||
break;
|
||||
default:
|
||||
event->ignore();
|
||||
break;
|
||||
|
@ -1323,7 +1318,7 @@ void Application::dropEvent(QDropEvent *event) {
|
|||
SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
|
||||
if (snapshotData) {
|
||||
if (!snapshotData->getDomain().isEmpty()) {
|
||||
// Menu::getInstance()->goToDomain(snapshotData->getDomain());
|
||||
changeDomainHostname(snapshotData->getDomain());
|
||||
}
|
||||
|
||||
_myAvatar->setPosition(snapshotData->getLocation());
|
||||
|
@ -3797,14 +3792,6 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
|||
|
||||
scriptEngine->registerGlobalObject("Overlays", &_overlays);
|
||||
|
||||
QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());
|
||||
// scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
||||
// LocationScriptingInterface::locationSetter, windowValue);
|
||||
//
|
||||
// // register `location` on the global object.
|
||||
// scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
||||
// LocationScriptingInterface::locationSetter);
|
||||
|
||||
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||
|
@ -3932,6 +3919,13 @@ void Application::uploadAttachment() {
|
|||
uploadModel(ATTACHMENT_MODEL);
|
||||
}
|
||||
|
||||
void Application::openUrl(const QUrl& url) {
|
||||
if (!AddressManager::getInstance().handleUrl(url)) {
|
||||
// address manager did not handle - ask QDesktopServices to handle
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) {
|
||||
|
||||
// from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
|
||||
|
@ -4120,37 +4114,3 @@ void Application::takeSnapshot() {
|
|||
}
|
||||
_snapshotShareDialog->show();
|
||||
}
|
||||
|
||||
void Application::urlGoTo(int argc, const char * constArgv[]) {
|
||||
//Gets the url (hifi://domain/destination/orientation)
|
||||
QString customUrl = getCmdOption(argc, constArgv, "-url");
|
||||
if(customUrl.startsWith(HIFI_URL_SCHEME + "//")) {
|
||||
QStringList urlParts = customUrl.remove(0, HIFI_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
|
||||
if (urlParts.count() == 1) {
|
||||
// location coordinates or place name
|
||||
QString domain = urlParts[0];
|
||||
// Menu::goToDomain(domain);
|
||||
} else if (urlParts.count() > 1) {
|
||||
// if url has 2 or more parts, the first one is domain name
|
||||
QString domain = urlParts[0];
|
||||
|
||||
// second part is either a destination coordinate or
|
||||
// a place name
|
||||
QString destination = urlParts[1];
|
||||
|
||||
// any third part is an avatar orientation.
|
||||
QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
|
||||
|
||||
// Menu::goToDomain(domain);
|
||||
|
||||
// goto either @user, #place, or x-xx,y-yy,z-zz
|
||||
// style co-ordinate.
|
||||
// Menu::goTo(destination);
|
||||
|
||||
if (!orientation.isEmpty()) {
|
||||
// location orientation
|
||||
// Menu::goToOrientation(orientation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,6 @@ public:
|
|||
void initializeGL();
|
||||
void paintGL();
|
||||
void resizeGL(int width, int height);
|
||||
void urlGoTo(int argc, const char * constArgv[]);
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
@ -352,6 +351,8 @@ public slots:
|
|||
void uploadHead();
|
||||
void uploadSkeleton();
|
||||
void uploadAttachment();
|
||||
|
||||
void openUrl(const QUrl& url);
|
||||
|
||||
void bumpSettings() { ++_numChangedSettings; }
|
||||
|
||||
|
|
|
@ -381,11 +381,11 @@ void ModelUploader::uploadSuccess(const QJsonObject& jsonResponse) {
|
|||
checkS3();
|
||||
}
|
||||
|
||||
void ModelUploader::uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString) {
|
||||
void ModelUploader::uploadFailed(QNetworkReply& errorReply) {
|
||||
if (_progressDialog) {
|
||||
_progressDialog->reject();
|
||||
}
|
||||
qDebug() << "Model upload failed (" << errorCode << "): " << errorString;
|
||||
qDebug() << "Model upload failed (" << errorReply.error() << "): " << errorReply.errorString();
|
||||
QMessageBox::warning(NULL,
|
||||
QString("ModelUploader::uploadFailed()"),
|
||||
QString("There was a problem with your upload, please try again later."),
|
||||
|
|
|
@ -43,7 +43,7 @@ private slots:
|
|||
void checkJSON(const QJsonObject& jsonResponse);
|
||||
void uploadUpdate(qint64 bytesSent, qint64 bytesTotal);
|
||||
void uploadSuccess(const QJsonObject& jsonResponse);
|
||||
void uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString);
|
||||
void uploadFailed(QNetworkReply& errorReply);
|
||||
void checkS3();
|
||||
void processCheck();
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ ChatMessageArea::ChatMessageArea(bool useFixedHeight) : QTextBrowser(), _useFixe
|
|||
|
||||
connect(document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged,
|
||||
this, &ChatMessageArea::updateLayout);
|
||||
// connect(this, &QTextBrowser::anchorClicked,
|
||||
// Menu::getInstance(), &Menu::openUrl);
|
||||
|
||||
connect(this, &QTextBrowser::anchorClicked, Application::getInstance(), &Application::openUrl);
|
||||
}
|
||||
|
||||
void ChatMessageArea::setHtml(const QString& html) {
|
||||
|
|
|
@ -49,6 +49,16 @@ const JSONCallbackParameters& AddressManager::apiCallbackParameters() {
|
|||
return callbackParams;
|
||||
}
|
||||
|
||||
bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
||||
if (lookupUrl.scheme() == HIFI_URL_SCHEME) {
|
||||
// we've verified that this is a valid hifi URL - hand it off to handleLookupString
|
||||
handleLookupString(lookupUrl.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddressManager::handleLookupString(const QString& lookupString) {
|
||||
// there are 4 possible lookup strings
|
||||
|
||||
|
@ -113,8 +123,8 @@ void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
|||
}
|
||||
}
|
||||
|
||||
void AddressManager::handleAPIError(QNetworkReply::NetworkError error, const QString& message) {
|
||||
qDebug() << "AddressManager API error -" << error << "-" << message;
|
||||
void AddressManager::handleAPIError(QNetworkReply& errorReply) {
|
||||
qDebug() << "AddressManager API error -" << errorReply.error() << "-" << errorReply.errorString();
|
||||
}
|
||||
|
||||
const QString GET_PLACE = "/api/v1/places/%1";
|
||||
|
|
|
@ -31,11 +31,12 @@ public:
|
|||
static QString pathForPositionAndOrientation(const glm::vec3& position, bool hasOrientation = false,
|
||||
const glm::quat& orientation = EMPTY_QUAT);
|
||||
|
||||
bool handleUrl(const QUrl& lookupUrl);
|
||||
void handleLookupString(const QString& lookupString);
|
||||
void attemptPlaceNameLookup(const QString& lookupString);
|
||||
public slots:
|
||||
void handleAPIResponse(const QJsonObject& jsonObject);
|
||||
void handleAPIError(QNetworkReply::NetworkError error, const QString& message);
|
||||
void handleAPIError(QNetworkReply& errorReply);
|
||||
signals:
|
||||
void lookupResultIsOffline();
|
||||
void possibleDomainChangeRequired(const QString& newHostname);
|
||||
|
|
|
@ -73,8 +73,8 @@ void UserActivityLogger::requestFinished(const QJsonObject& object) {
|
|||
// qDebug() << object;
|
||||
}
|
||||
|
||||
void UserActivityLogger::requestError(QNetworkReply::NetworkError error,const QString& string) {
|
||||
qDebug() << error << ": " << string;
|
||||
void UserActivityLogger::requestError(QNetworkReply& errorReply) {
|
||||
qDebug() << errorReply.error() << "-" << errorReply.errorString();
|
||||
}
|
||||
|
||||
void UserActivityLogger::launch(QString applicationVersion) {
|
||||
|
|
|
@ -40,7 +40,7 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void requestFinished(const QJsonObject& object);
|
||||
void requestError(QNetworkReply::NetworkError error,const QString& string);
|
||||
void requestError(QNetworkReply& errorReply);
|
||||
|
||||
private:
|
||||
UserActivityLogger();
|
||||
|
|
Loading…
Reference in a new issue