mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #1039 from birarda/data-server
add ability to jump to a user's domain and location
This commit is contained in:
commit
43e01ee105
8 changed files with 273 additions and 125 deletions
|
@ -102,6 +102,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_voxelImporter(_window),
|
_voxelImporter(_window),
|
||||||
_wantToKillLocalVoxels(false),
|
_wantToKillLocalVoxels(false),
|
||||||
_audioScope(256, 200, true),
|
_audioScope(256, 200, true),
|
||||||
|
_profile(QString()),
|
||||||
_mouseX(0),
|
_mouseX(0),
|
||||||
_mouseY(0),
|
_mouseY(0),
|
||||||
_touchAvgX(0.0f),
|
_touchAvgX(0.0f),
|
||||||
|
@ -181,10 +182,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
|
|
||||||
_settings = new QSettings(this);
|
_settings = new QSettings(this);
|
||||||
|
|
||||||
// check if there is a saved domain server hostname
|
// call Menu getInstance static method to set up the menu
|
||||||
// this must be done now instead of with the other setting checks to allow manual override with
|
_window->setMenuBar(Menu::getInstance());
|
||||||
// --domain or --local options
|
|
||||||
NodeList::getInstance()->loadData(_settings);
|
|
||||||
|
|
||||||
// Check to see if the user passed in a command line option for loading a local
|
// Check to see if the user passed in a command line option for loading a local
|
||||||
// Voxel File.
|
// Voxel File.
|
||||||
|
@ -206,9 +205,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
NodeList::getInstance()->startSilentNodeRemovalThread();
|
NodeList::getInstance()->startSilentNodeRemovalThread();
|
||||||
|
|
||||||
_window->setCentralWidget(_glWidget);
|
_window->setCentralWidget(_glWidget);
|
||||||
|
|
||||||
// call Menu getInstance static method to set up the menu
|
|
||||||
_window->setMenuBar(Menu::getInstance());
|
|
||||||
|
|
||||||
_networkAccessManager = new QNetworkAccessManager(this);
|
_networkAccessManager = new QNetworkAccessManager(this);
|
||||||
QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager);
|
QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager);
|
||||||
|
@ -455,6 +451,12 @@ void Application::updateProjectionMatrix() {
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::resetProfile(const QString& username) {
|
||||||
|
// call the destructor on the old profile and construct a new one
|
||||||
|
(&_profile)->~Profile();
|
||||||
|
new (&_profile) Profile(username);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
const char* nodeTypes, int numNodeTypes) {
|
const char* nodeTypes, int numNodeTypes) {
|
||||||
Application* self = getInstance();
|
Application* self = getInstance();
|
||||||
|
@ -1158,6 +1160,9 @@ void Application::timer() {
|
||||||
|
|
||||||
// ask the node list to check in with the domain server
|
// ask the node list to check in with the domain server
|
||||||
NodeList::getInstance()->sendDomainServerCheckIn();
|
NodeList::getInstance()->sendDomainServerCheckIn();
|
||||||
|
|
||||||
|
// give the MyAvatar object position to the Profile so it can propagate to the data-server
|
||||||
|
_profile.updatePosition(_myAvatar.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
static glm::vec3 getFaceVector(BoxFace face) {
|
static glm::vec3 getFaceVector(BoxFace face) {
|
||||||
|
@ -3517,9 +3522,13 @@ void Application::attachNewHeadToNode(Node* newNode) {
|
||||||
void Application::domainChanged(QString domain) {
|
void Application::domainChanged(QString domain) {
|
||||||
qDebug("Application title set to: %s.\n", domain.toStdString().c_str());
|
qDebug("Application title set to: %s.\n", domain.toStdString().c_str());
|
||||||
_window->setWindowTitle(domain);
|
_window->setWindowTitle(domain);
|
||||||
|
|
||||||
|
// update the user's last domain in their Profile (which will propagate to data-server)
|
||||||
|
_profile.updateDomain(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::nodeAdded(Node* node) {
|
void Application::nodeAdded(Node* node) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::nodeKilled(Node* node) {
|
void Application::nodeKilled(Node* node) {
|
||||||
|
|
|
@ -112,7 +112,6 @@ public:
|
||||||
|
|
||||||
QGLWidget* getGLWidget() { return _glWidget; }
|
QGLWidget* getGLWidget() { return _glWidget; }
|
||||||
MyAvatar* getAvatar() { return &_myAvatar; }
|
MyAvatar* getAvatar() { return &_myAvatar; }
|
||||||
Profile* getProfile() { return &_profile; }
|
|
||||||
Audio* getAudio() { return &_audio; }
|
Audio* getAudio() { return &_audio; }
|
||||||
Camera* getCamera() { return &_myCamera; }
|
Camera* getCamera() { return &_myCamera; }
|
||||||
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
||||||
|
@ -136,6 +135,9 @@ public:
|
||||||
|
|
||||||
Avatar* getLookatTargetAvatar() const { return _lookatTargetAvatar; }
|
Avatar* getLookatTargetAvatar() const { return _lookatTargetAvatar; }
|
||||||
|
|
||||||
|
Profile* getProfile() { return &_profile; }
|
||||||
|
void resetProfile(const QString& username);
|
||||||
|
|
||||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
const char* nodeTypes, int numNodeTypes);
|
const char* nodeTypes, int numNodeTypes);
|
||||||
|
|
||||||
|
|
|
@ -18,19 +18,16 @@
|
||||||
|
|
||||||
#include "DataServerClient.h"
|
#include "DataServerClient.h"
|
||||||
|
|
||||||
|
|
||||||
std::map<unsigned char*, int> DataServerClient::_unmatchedPackets;
|
std::map<unsigned char*, int> DataServerClient::_unmatchedPackets;
|
||||||
|
|
||||||
|
const char MULTI_KEY_VALUE_SEPARATOR = '|';
|
||||||
|
|
||||||
const char DATA_SERVER_HOSTNAME[] = "data.highfidelity.io";
|
const char DATA_SERVER_HOSTNAME[] = "data.highfidelity.io";
|
||||||
const unsigned short DATA_SERVER_PORT = 3282;
|
const unsigned short DATA_SERVER_PORT = 3282;
|
||||||
const sockaddr_in DATA_SERVER_SOCKET = socketForHostnameAndHostOrderPort(DATA_SERVER_HOSTNAME, DATA_SERVER_PORT);
|
const sockaddr_in DATA_SERVER_SOCKET = socketForHostnameAndHostOrderPort(DATA_SERVER_HOSTNAME, DATA_SERVER_PORT);
|
||||||
|
|
||||||
void DataServerClient::putValueForKey(const char* key, const char* value) {
|
void DataServerClient::putValueForKey(const QString& key, const char* value) {
|
||||||
Profile* userProfile = Application::getInstance()->getProfile();
|
QString clientString = Application::getInstance()->getProfile()->getUserString();
|
||||||
QString clientString = userProfile->getUUID().isNull()
|
|
||||||
? userProfile->getUsername()
|
|
||||||
: uuidStringWithoutCurlyBraces(userProfile->getUUID().toString());
|
|
||||||
|
|
||||||
if (!clientString.isEmpty()) {
|
if (!clientString.isEmpty()) {
|
||||||
|
|
||||||
unsigned char* putPacket = new unsigned char[MAX_PACKET_SIZE];
|
unsigned char* putPacket = new unsigned char[MAX_PACKET_SIZE];
|
||||||
|
@ -43,9 +40,12 @@ void DataServerClient::putValueForKey(const char* key, const char* value) {
|
||||||
numPacketBytes += clientString.toLocal8Bit().size();
|
numPacketBytes += clientString.toLocal8Bit().size();
|
||||||
putPacket[numPacketBytes++] = '\0';
|
putPacket[numPacketBytes++] = '\0';
|
||||||
|
|
||||||
|
// pack a 1 to designate that we are putting a single value
|
||||||
|
putPacket[numPacketBytes++] = 1;
|
||||||
|
|
||||||
// pack the key, null terminated
|
// pack the key, null terminated
|
||||||
strcpy((char*) putPacket + numPacketBytes, key);
|
strcpy((char*) putPacket + numPacketBytes, key.toLocal8Bit().constData());
|
||||||
numPacketBytes += strlen(key);
|
numPacketBytes += key.size();
|
||||||
putPacket[numPacketBytes++] = '\0';
|
putPacket[numPacketBytes++] = '\0';
|
||||||
|
|
||||||
// pack the value, null terminated
|
// pack the value, null terminated
|
||||||
|
@ -54,48 +54,54 @@ void DataServerClient::putValueForKey(const char* key, const char* value) {
|
||||||
putPacket[numPacketBytes++] = '\0';
|
putPacket[numPacketBytes++] = '\0';
|
||||||
|
|
||||||
// add the putPacket to our vector of unconfirmed packets, will be deleted once put is confirmed
|
// add the putPacket to our vector of unconfirmed packets, will be deleted once put is confirmed
|
||||||
_unmatchedPackets.insert(std::pair<unsigned char*, int>(putPacket, numPacketBytes));
|
// _unmatchedPackets.insert(std::pair<unsigned char*, int>(putPacket, numPacketBytes));
|
||||||
|
|
||||||
// send this put request to the data server
|
// send this put request to the data server
|
||||||
NodeList::getInstance()->getNodeSocket()->send((sockaddr*) &DATA_SERVER_SOCKET, putPacket, numPacketBytes);
|
NodeList::getInstance()->getNodeSocket()->send((sockaddr*) &DATA_SERVER_SOCKET, putPacket, numPacketBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataServerClient::getValueForKeyAndUUID(const char* key, const QUuid &uuid) {
|
void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uuid) {
|
||||||
|
getValuesForKeysAndUUID(QStringList(key), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid) {
|
||||||
if (!uuid.isNull()) {
|
if (!uuid.isNull()) {
|
||||||
getValueForKeyAndUserString(key, uuidStringWithoutCurlyBraces(uuid));
|
getValuesForKeysAndUserString(keys, uuidStringWithoutCurlyBraces(uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataServerClient::getValueForKeyAndUserString(const char* key, const QString& userString) {
|
void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, const QString& userString) {
|
||||||
unsigned char* getPacket = new unsigned char[MAX_PACKET_SIZE];
|
if (!userString.isEmpty() && keys.size() <= UCHAR_MAX) {
|
||||||
|
unsigned char* getPacket = new unsigned char[MAX_PACKET_SIZE];
|
||||||
// setup the header for this packet
|
|
||||||
int numPacketBytes = populateTypeAndVersion(getPacket, PACKET_TYPE_DATA_SERVER_GET);
|
// setup the header for this packet
|
||||||
|
int numPacketBytes = populateTypeAndVersion(getPacket, PACKET_TYPE_DATA_SERVER_GET);
|
||||||
// pack the user string (could be username or UUID string), null-terminate
|
|
||||||
memcpy(getPacket + numPacketBytes, userString.toLocal8Bit().constData(), userString.toLocal8Bit().size());
|
// pack the user string (could be username or UUID string), null-terminate
|
||||||
numPacketBytes += userString.toLocal8Bit().size();
|
memcpy(getPacket + numPacketBytes, userString.toLocal8Bit().constData(), userString.toLocal8Bit().size());
|
||||||
getPacket[numPacketBytes++] = '\0';
|
numPacketBytes += userString.toLocal8Bit().size();
|
||||||
|
|
||||||
// pack the key, null terminated
|
|
||||||
strcpy((char*) getPacket + numPacketBytes, key);
|
|
||||||
int numKeyBytes = strlen(key);
|
|
||||||
|
|
||||||
if (numKeyBytes > 0) {
|
|
||||||
numPacketBytes += numKeyBytes;
|
|
||||||
getPacket[numPacketBytes++] = '\0';
|
getPacket[numPacketBytes++] = '\0';
|
||||||
|
|
||||||
|
// pack one byte to designate the number of keys
|
||||||
|
getPacket[numPacketBytes++] = keys.size();
|
||||||
|
|
||||||
|
QString keyString = keys.join(MULTI_KEY_VALUE_SEPARATOR);
|
||||||
|
|
||||||
|
// pack the key string, null terminated
|
||||||
|
strcpy((char*) getPacket + numPacketBytes, keyString.toLocal8Bit().constData());
|
||||||
|
numPacketBytes += keyString.size() + sizeof('\0');
|
||||||
|
|
||||||
|
// add the getPacket to our vector of uncofirmed packets, will be deleted once we get a response from the nameserver
|
||||||
|
// _unmatchedPackets.insert(std::pair<unsigned char*, int>(getPacket, numPacketBytes));
|
||||||
|
|
||||||
|
// send the get to the data server
|
||||||
|
NodeList::getInstance()->getNodeSocket()->send((sockaddr*) &DATA_SERVER_SOCKET, getPacket, numPacketBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the getPacket to our vector of uncofirmed packets, will be deleted once we get a response from the nameserver
|
|
||||||
_unmatchedPackets.insert(std::pair<unsigned char*, int>(getPacket, numPacketBytes));
|
|
||||||
|
|
||||||
// send the get to the data server
|
|
||||||
NodeList::getInstance()->getNodeSocket()->send((sockaddr*) &DATA_SERVER_SOCKET, getPacket, numPacketBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataServerClient::getClientValueForKey(const char* key) {
|
void DataServerClient::getClientValueForKey(const QString& key) {
|
||||||
getValueForKeyAndUserString(key, Application::getInstance()->getProfile()->getUsername());
|
getValuesForKeysAndUserString(QStringList(key), Application::getInstance()->getProfile()->getUserString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataServerClient::processConfirmFromDataServer(unsigned char* packetData, int numPacketBytes) {
|
void DataServerClient::processConfirmFromDataServer(unsigned char* packetData, int numPacketBytes) {
|
||||||
|
@ -112,45 +118,63 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int
|
||||||
|
|
||||||
QUuid userUUID(userString);
|
QUuid userUUID(userString);
|
||||||
|
|
||||||
char* dataKeyPosition = (char*) packetData + numHeaderBytes + strlen(userStringPosition) + sizeof('\0');
|
char* keysPosition = (char*) packetData + numHeaderBytes + strlen(userStringPosition)
|
||||||
char* dataValuePosition = dataKeyPosition + strlen(dataKeyPosition) + sizeof(char);
|
+ sizeof('\0') + sizeof(unsigned char);
|
||||||
|
char* valuesPosition = keysPosition + strlen(keysPosition) + sizeof('\0');
|
||||||
|
|
||||||
QString dataValueString(QByteArray(dataValuePosition,
|
QStringList keyList = QString(keysPosition).split(MULTI_KEY_VALUE_SEPARATOR);
|
||||||
numPacketBytes - ((unsigned char*) dataValuePosition - packetData)));
|
QStringList valueList = QString(valuesPosition).split(MULTI_KEY_VALUE_SEPARATOR);
|
||||||
|
|
||||||
if (userUUID.isNull()) {
|
// user string was UUID, find matching avatar and associate data
|
||||||
// the user string was a username
|
for (int i = 0; i < keyList.size(); i++) {
|
||||||
// for now assume this means that it is for our avatar
|
if (valueList[i] != " ") {
|
||||||
|
if (keyList[i] == DataServerKey::FaceMeshURL) {
|
||||||
if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL) == 0) {
|
|
||||||
// pull the user's face mesh and set it on the Avatar instance
|
if (userUUID.isNull() || userUUID == Application::getInstance()->getProfile()->getUUID()) {
|
||||||
|
qDebug("Changing user's face model URL to %s\n", valueList[0].toLocal8Bit().constData());
|
||||||
qDebug("Changing user's face model URL to %s\n", dataValueString.toLocal8Bit().constData());
|
Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[0]));
|
||||||
Application::getInstance()->getProfile()->setFaceModelURL(QUrl(dataValueString));
|
} else {
|
||||||
} else if (strcmp(dataKeyPosition, DataServerKey::UUID) == 0) {
|
// mesh URL for a UUID, find avatar in our list
|
||||||
// this is the user's UUID - set it on the profile
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
Application::getInstance()->getProfile()->setUUID(dataValueString);
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
}
|
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||||
} else {
|
Avatar* avatar = (Avatar *) node->getLinkedData();
|
||||||
// user string was UUID, find matching avatar and associate data
|
|
||||||
if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL) == 0) {
|
if (avatar->getUUID() == userUUID) {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
QMetaObject::invokeMethod(&avatar->getHead().getBlendFace(),
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
"setModelURL",
|
||||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
Q_ARG(QUrl, QUrl(valueList[0])));
|
||||||
Avatar* avatar = (Avatar *) node->getLinkedData();
|
}
|
||||||
|
}
|
||||||
if (avatar->getUUID() == userUUID) {
|
|
||||||
QMetaObject::invokeMethod(&avatar->getHead().getBlendFace(),
|
|
||||||
"setModelURL",
|
|
||||||
Q_ARG(QUrl, QUrl(dataValueString)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (keyList[i] == DataServerKey::Domain) {
|
||||||
|
qDebug() << "Changing domain hostname to" << valueList[i].toLocal8Bit().constData() <<
|
||||||
|
"to go to" << userString << "\n";
|
||||||
|
NodeList::getInstance()->setDomainHostname(valueList[i]);
|
||||||
|
} else if (keyList[i] == DataServerKey::Position) {
|
||||||
|
QStringList coordinateItems = valueList[i].split(',');
|
||||||
|
|
||||||
|
if (coordinateItems.size() == 3) {
|
||||||
|
qDebug() << "Changing position to" << valueList[i].toLocal8Bit().constData() <<
|
||||||
|
"to go to" << userString << "\n";
|
||||||
|
|
||||||
|
glm::vec3 newPosition(coordinateItems[0].toFloat(),
|
||||||
|
coordinateItems[1].toFloat(),
|
||||||
|
coordinateItems[2].toFloat());
|
||||||
|
Application::getInstance()->getAvatar()->setPosition(newPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else if (keyList[i] == DataServerKey::UUID) {
|
||||||
|
// this is the user's UUID - set it on the profile
|
||||||
|
Application::getInstance()->getProfile()->setUUID(valueList[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the matched packet from our map so it isn't re-sent to the data-server
|
// remove the matched packet from our map so it isn't re-sent to the data-server
|
||||||
removeMatchedPacketFromMap(packetData, numPacketBytes);
|
// removeMatchedPacketFromMap(packetData, numPacketBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataServerClient::processMessageFromDataServer(unsigned char* packetData, int numPacketBytes) {
|
void DataServerClient::processMessageFromDataServer(unsigned char* packetData, int numPacketBytes) {
|
||||||
|
|
|
@ -17,22 +17,29 @@
|
||||||
|
|
||||||
class DataServerClient {
|
class DataServerClient {
|
||||||
public:
|
public:
|
||||||
static void putValueForKey(const char* key, const char* value);
|
static void putValueForKey(const QString& key, const char* value);
|
||||||
static void getValueForKeyAndUUID(const char* key, const QUuid& uuid);
|
static void getClientValueForKey(const QString& key);
|
||||||
static void getValueForKeyAndUserString(const char* key, const QString& userString);
|
|
||||||
static void getClientValueForKey(const char* key);
|
static void getValueForKeyAndUUID(const QString& key, const QUuid& uuid);
|
||||||
|
static void getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid);
|
||||||
|
static void getValuesForKeysAndUserString(const QStringList& keys, const QString& userString);
|
||||||
|
|
||||||
static void processConfirmFromDataServer(unsigned char* packetData, int numPacketBytes);
|
static void processConfirmFromDataServer(unsigned char* packetData, int numPacketBytes);
|
||||||
static void processSendFromDataServer(unsigned char* packetData, int numPacketBytes);
|
static void processSendFromDataServer(unsigned char* packetData, int numPacketBytes);
|
||||||
static void processMessageFromDataServer(unsigned char* packetData, int numPacketBytes);
|
static void processMessageFromDataServer(unsigned char* packetData, int numPacketBytes);
|
||||||
static void removeMatchedPacketFromMap(unsigned char* packetData, int numPacketBytes);
|
static void removeMatchedPacketFromMap(unsigned char* packetData, int numPacketBytes);
|
||||||
static void resendUnmatchedPackets();
|
static void resendUnmatchedPackets();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
static std::map<unsigned char*, int> _unmatchedPackets;
|
static std::map<unsigned char*, int> _unmatchedPackets;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace DataServerKey {
|
namespace DataServerKey {
|
||||||
const char FaceMeshURL[] = "mesh";
|
const QString Domain = "domain";
|
||||||
const char UUID[] = "uuid";
|
const QString FaceMeshURL = "mesh";
|
||||||
|
const QString Position = "position";
|
||||||
|
const QString UUID = "uuid";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined(__hifi__DataServerClient__) */
|
#endif /* defined(__hifi__DataServerClient__) */
|
||||||
|
|
|
@ -67,6 +67,12 @@ Menu::Menu() :
|
||||||
SLOT(aboutApp())))->setMenuRole(QAction::AboutRole);
|
SLOT(aboutApp())))->setMenuRole(QAction::AboutRole);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
(addActionToQMenuAndActionHash(fileMenu,
|
||||||
|
MenuOption::Login,
|
||||||
|
0,
|
||||||
|
this,
|
||||||
|
SLOT(login())));
|
||||||
|
|
||||||
(addActionToQMenuAndActionHash(fileMenu,
|
(addActionToQMenuAndActionHash(fileMenu,
|
||||||
MenuOption::Preferences,
|
MenuOption::Preferences,
|
||||||
Qt::CTRL | Qt::Key_Comma,
|
Qt::CTRL | Qt::Key_Comma,
|
||||||
|
@ -93,6 +99,11 @@ Menu::Menu() :
|
||||||
Qt::CTRL | Qt::SHIFT | Qt::Key_L,
|
Qt::CTRL | Qt::SHIFT | Qt::Key_L,
|
||||||
this,
|
this,
|
||||||
SLOT(goToLocation()));
|
SLOT(goToLocation()));
|
||||||
|
addActionToQMenuAndActionHash(fileMenu,
|
||||||
|
MenuOption::GoToUser,
|
||||||
|
Qt::CTRL | Qt::SHIFT | Qt::Key_U,
|
||||||
|
this,
|
||||||
|
SLOT(goToUser()));
|
||||||
|
|
||||||
|
|
||||||
addDisabledActionAndSeparator(fileMenu, "Settings");
|
addDisabledActionAndSeparator(fileMenu, "Settings");
|
||||||
|
@ -507,9 +518,10 @@ void Menu::loadSettings(QSettings* settings) {
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
scanMenuBar(&loadAction, settings);
|
scanMenuBar(&loadAction, settings);
|
||||||
Application::getInstance()->getProfile()->loadData(settings);
|
|
||||||
Application::getInstance()->getAvatar()->loadData(settings);
|
Application::getInstance()->getAvatar()->loadData(settings);
|
||||||
Application::getInstance()->getSwatch()->loadData(settings);
|
Application::getInstance()->getSwatch()->loadData(settings);
|
||||||
|
Application::getInstance()->getProfile()->loadData(settings);
|
||||||
|
NodeList::getInstance()->loadData(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::saveSettings(QSettings* settings) {
|
void Menu::saveSettings(QSettings* settings) {
|
||||||
|
@ -530,10 +542,8 @@ void Menu::saveSettings(QSettings* settings) {
|
||||||
|
|
||||||
scanMenuBar(&saveAction, settings);
|
scanMenuBar(&saveAction, settings);
|
||||||
Application::getInstance()->getAvatar()->saveData(settings);
|
Application::getInstance()->getAvatar()->saveData(settings);
|
||||||
Application::getInstance()->getProfile()->saveData(settings);
|
|
||||||
Application::getInstance()->getSwatch()->saveData(settings);
|
Application::getInstance()->getSwatch()->saveData(settings);
|
||||||
|
Application::getInstance()->getProfile()->saveData(settings);
|
||||||
// ask the NodeList to save its data
|
|
||||||
NodeList::getInstance()->saveData(settings);
|
NodeList::getInstance()->saveData(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,6 +759,40 @@ QLineEdit* lineEditForDomainHostname() {
|
||||||
return domainServerLineEdit;
|
return domainServerLineEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Menu::login() {
|
||||||
|
Application* applicationInstance = Application::getInstance();
|
||||||
|
QDialog dialog(applicationInstance->getGLWidget());
|
||||||
|
dialog.setWindowTitle("Login");
|
||||||
|
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
|
dialog.setLayout(layout);
|
||||||
|
|
||||||
|
QFormLayout* form = new QFormLayout();
|
||||||
|
layout->addLayout(form, 1);
|
||||||
|
|
||||||
|
QString username = applicationInstance->getProfile()->getUsername();
|
||||||
|
QLineEdit* usernameLineEdit = new QLineEdit(username);
|
||||||
|
usernameLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
|
form->addRow("Username:", usernameLineEdit);
|
||||||
|
|
||||||
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||||
|
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
||||||
|
layout->addWidget(buttons);
|
||||||
|
|
||||||
|
int ret = dialog.exec();
|
||||||
|
applicationInstance->getWindow()->activateWindow();
|
||||||
|
if (ret != QDialog::Accepted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usernameLineEdit->text() != username) {
|
||||||
|
// there has been a username change
|
||||||
|
// ask for a profile reset with the new username
|
||||||
|
applicationInstance->resetProfile(usernameLineEdit->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::editPreferences() {
|
void Menu::editPreferences() {
|
||||||
Application* applicationInstance = Application::getInstance();
|
Application* applicationInstance = Application::getInstance();
|
||||||
|
|
||||||
|
@ -760,11 +804,6 @@ void Menu::editPreferences() {
|
||||||
QFormLayout* form = new QFormLayout();
|
QFormLayout* form = new QFormLayout();
|
||||||
layout->addLayout(form, 1);
|
layout->addLayout(form, 1);
|
||||||
|
|
||||||
QString avatarUsername = applicationInstance->getProfile()->getUsername();
|
|
||||||
QLineEdit* avatarUsernameEdit = new QLineEdit(avatarUsername);
|
|
||||||
avatarUsernameEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
|
||||||
form->addRow("Username:", avatarUsernameEdit);
|
|
||||||
|
|
||||||
QLineEdit* avatarURL = new QLineEdit(applicationInstance->getAvatar()->getVoxels()->getVoxelURL().toString());
|
QLineEdit* avatarURL = new QLineEdit(applicationInstance->getAvatar()->getVoxels()->getVoxelURL().toString());
|
||||||
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
form->addRow("Avatar URL:", avatarURL);
|
form->addRow("Avatar URL:", avatarURL);
|
||||||
|
@ -817,17 +856,6 @@ void Menu::editPreferences() {
|
||||||
|
|
||||||
QUrl faceModelURL(faceURLEdit->text());
|
QUrl faceModelURL(faceURLEdit->text());
|
||||||
|
|
||||||
|
|
||||||
if (avatarUsernameEdit->text() != avatarUsername) {
|
|
||||||
// there has been a username change - set the new UUID on the avatar instance
|
|
||||||
applicationInstance->getProfile()->setUsername(avatarUsernameEdit->text());
|
|
||||||
|
|
||||||
if (faceModelURL.toString() == faceURLString && !avatarUsernameEdit->text().isEmpty()) {
|
|
||||||
// if there was no change to the face model URL then ask the data-server for what it is
|
|
||||||
DataServerClient::getClientValueForKey(DataServerKey::FaceMeshURL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faceModelURL.toString() != faceURLString) {
|
if (faceModelURL.toString() != faceURLString) {
|
||||||
// change the faceModelURL in the profile, it will also update this user's BlendFace
|
// change the faceModelURL in the profile, it will also update this user's BlendFace
|
||||||
applicationInstance->getProfile()->setFaceModelURL(faceModelURL);
|
applicationInstance->getProfile()->setFaceModelURL(faceModelURL);
|
||||||
|
@ -946,6 +974,37 @@ void Menu::goToLocation() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menu::goToUser() {
|
||||||
|
Application* applicationInstance = Application::getInstance();
|
||||||
|
QDialog dialog(applicationInstance->getGLWidget());
|
||||||
|
dialog.setWindowTitle("Go To User");
|
||||||
|
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
|
dialog.setLayout(layout);
|
||||||
|
|
||||||
|
QFormLayout* form = new QFormLayout();
|
||||||
|
layout->addLayout(form, 1);
|
||||||
|
|
||||||
|
QLineEdit* usernameLineEdit = new QLineEdit();
|
||||||
|
usernameLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
|
form->addRow("", usernameLineEdit);
|
||||||
|
|
||||||
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||||
|
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
||||||
|
layout->addWidget(buttons);
|
||||||
|
|
||||||
|
int ret = dialog.exec();
|
||||||
|
applicationInstance->getWindow()->activateWindow();
|
||||||
|
if (ret != QDialog::Accepted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!usernameLineEdit->text().isEmpty()) {
|
||||||
|
// there's a username entered by the user, make a request to the data-server
|
||||||
|
DataServerClient::getValuesForKeysAndUserString((QStringList() << DataServerKey::Domain << DataServerKey::Position),
|
||||||
|
usernameLineEdit->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::bandwidthDetails() {
|
void Menu::bandwidthDetails() {
|
||||||
|
|
||||||
|
|
|
@ -69,9 +69,11 @@ public slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void aboutApp();
|
void aboutApp();
|
||||||
|
void login();
|
||||||
void editPreferences();
|
void editPreferences();
|
||||||
void goToDomain();
|
void goToDomain();
|
||||||
void goToLocation();
|
void goToLocation();
|
||||||
|
void goToUser();
|
||||||
void bandwidthDetailsClosed();
|
void bandwidthDetailsClosed();
|
||||||
void voxelStatsDetailsClosed();
|
void voxelStatsDetailsClosed();
|
||||||
void cycleFrustumRenderMode();
|
void cycleFrustumRenderMode();
|
||||||
|
@ -120,7 +122,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace MenuOption {
|
namespace MenuOption {
|
||||||
|
|
||||||
const QString AboutApp = "About Interface";
|
const QString AboutApp = "About Interface";
|
||||||
const QString AmbientOcclusion = "Ambient Occlusion";
|
const QString AmbientOcclusion = "Ambient Occlusion";
|
||||||
const QString Avatars = "Avatars";
|
const QString Avatars = "Avatars";
|
||||||
|
@ -161,6 +162,7 @@ namespace MenuOption {
|
||||||
const QString GlowMode = "Cycle Glow Mode";
|
const QString GlowMode = "Cycle Glow Mode";
|
||||||
const QString GoToDomain = "Go To Domain...";
|
const QString GoToDomain = "Go To Domain...";
|
||||||
const QString GoToLocation = "Go To Location...";
|
const QString GoToLocation = "Go To Location...";
|
||||||
|
const QString GoToUser = "Go To User...";
|
||||||
const QString ImportVoxels = "Import Voxels";
|
const QString ImportVoxels = "Import Voxels";
|
||||||
const QString ImportVoxelsClipboard = "Import Voxels to Clipboard";
|
const QString ImportVoxelsClipboard = "Import Voxels to Clipboard";
|
||||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||||
|
@ -174,6 +176,7 @@ namespace MenuOption {
|
||||||
const QString ListenModePoint = "Listen Mode Point";
|
const QString ListenModePoint = "Listen Mode Point";
|
||||||
const QString ListenModeSingleSource = "Listen Mode Single Source";
|
const QString ListenModeSingleSource = "Listen Mode Single Source";
|
||||||
const QString Log = "Log";
|
const QString Log = "Log";
|
||||||
|
const QString Login = "Login";
|
||||||
const QString LookAtIndicator = "Look-at Indicator";
|
const QString LookAtIndicator = "Look-at Indicator";
|
||||||
const QString LookAtVectors = "Look-at Vectors";
|
const QString LookAtVectors = "Look-at Vectors";
|
||||||
const QString LowRes = "Lower Resolution While Moving";
|
const QString LowRes = "Lower Resolution While Moving";
|
||||||
|
|
|
@ -8,33 +8,32 @@
|
||||||
|
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
|
||||||
|
#include <UUID.h>
|
||||||
|
|
||||||
#include "Profile.h"
|
#include "Profile.h"
|
||||||
#include "DataServerClient.h"
|
#include "DataServerClient.h"
|
||||||
|
|
||||||
Profile::Profile() :
|
Profile::Profile(const QString &username) :
|
||||||
_username(),
|
_username(username),
|
||||||
_uuid(),
|
_uuid(),
|
||||||
_faceModelURL()
|
_lastDomain(),
|
||||||
|
_lastPosition(0.0, 0.0, 0.0),
|
||||||
|
_faceModelURL()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::clear() {
|
|
||||||
_username.clear();
|
|
||||||
_uuid = QUuid();
|
|
||||||
_faceModelURL.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::setUsername(const QString &username) {
|
|
||||||
this->clear();
|
|
||||||
_username = username;
|
|
||||||
|
|
||||||
if (!_username.isEmpty()) {
|
if (!_username.isEmpty()) {
|
||||||
// we've been given a new username, ask the data-server for our UUID
|
// we've been given a new username, ask the data-server for profile
|
||||||
DataServerClient::getClientValueForKey(DataServerKey::UUID);
|
DataServerClient::getClientValueForKey(DataServerKey::UUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Profile::getUserString() const {
|
||||||
|
if (_uuid.isNull()) {
|
||||||
|
return _username;
|
||||||
|
} else {
|
||||||
|
return uuidStringWithoutCurlyBraces(_uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Profile::setUUID(const QUuid& uuid) {
|
void Profile::setUUID(const QUuid& uuid) {
|
||||||
_uuid = uuid;
|
_uuid = uuid;
|
||||||
|
|
||||||
|
@ -50,6 +49,42 @@ void Profile::setFaceModelURL(const QUrl& faceModelURL) {
|
||||||
Q_ARG(QUrl, _faceModelURL));
|
Q_ARG(QUrl, _faceModelURL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Profile::updateDomain(const QString& domain) {
|
||||||
|
if (_lastDomain != domain) {
|
||||||
|
_lastDomain = domain;
|
||||||
|
|
||||||
|
// send the changed domain to the data-server
|
||||||
|
DataServerClient::putValueForKey(DataServerKey::Domain, domain.toLocal8Bit().constData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Profile::updatePosition(const glm::vec3 position) {
|
||||||
|
if (_lastPosition != position) {
|
||||||
|
|
||||||
|
static timeval lastPositionSend = {};
|
||||||
|
const uint64_t DATA_SERVER_POSITION_UPDATE_INTERVAL_USECS = 5 * 1000 * 1000;
|
||||||
|
const float DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS = 1;
|
||||||
|
|
||||||
|
if (usecTimestampNow() - usecTimestamp(&lastPositionSend) >= DATA_SERVER_POSITION_UPDATE_INTERVAL_USECS &&
|
||||||
|
(fabsf(_lastPosition.x - position.x) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS ||
|
||||||
|
fabsf(_lastPosition.y - position.y) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS ||
|
||||||
|
fabsf(_lastPosition.z - position.z) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS)) {
|
||||||
|
|
||||||
|
// if it has been 5 seconds since the last position change and the user has moved >= the threshold
|
||||||
|
// in at least one of the axis then send the position update to the data-server
|
||||||
|
|
||||||
|
_lastPosition = position;
|
||||||
|
|
||||||
|
// update the lastPositionSend to now
|
||||||
|
gettimeofday(&lastPositionSend, NULL);
|
||||||
|
|
||||||
|
// send the changed position to the data-server
|
||||||
|
QString positionString = QString("%1,%2,%3").arg(position.x).arg(position.y).arg(position.z);
|
||||||
|
DataServerClient::putValueForKey(DataServerKey::Position, positionString.toLocal8Bit().constData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Profile::saveData(QSettings* settings) {
|
void Profile::saveData(QSettings* settings) {
|
||||||
settings->beginGroup("Profile");
|
settings->beginGroup("Profile");
|
||||||
|
|
||||||
|
|
|
@ -13,26 +13,35 @@
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
class Profile {
|
class Profile {
|
||||||
public:
|
public:
|
||||||
Profile();
|
Profile(const QString& username);
|
||||||
|
|
||||||
void setUsername(const QString& username);
|
QString getUserString() const;
|
||||||
QString& getUsername() { return _username; }
|
|
||||||
|
const QString& getUsername() const { return _username; }
|
||||||
|
|
||||||
void setUUID(const QUuid& uuid);
|
void setUUID(const QUuid& uuid);
|
||||||
QUuid& getUUID() { return _uuid; }
|
const QUuid& getUUID() { return _uuid; }
|
||||||
|
|
||||||
void setFaceModelURL(const QUrl& faceModelURL);
|
void setFaceModelURL(const QUrl& faceModelURL);
|
||||||
QUrl& getFaceModelURL() { return _faceModelURL; }
|
const QUrl& getFaceModelURL() const { return _faceModelURL; }
|
||||||
|
|
||||||
void clear();
|
void updateDomain(const QString& domain);
|
||||||
|
void updatePosition(const glm::vec3 position);
|
||||||
|
|
||||||
|
QString getLastDomain() const { return _lastDomain; }
|
||||||
|
const glm::vec3& getLastPosition() const { return _lastPosition; }
|
||||||
|
|
||||||
void saveData(QSettings* settings);
|
void saveData(QSettings* settings);
|
||||||
void loadData(QSettings* settings);
|
void loadData(QSettings* settings);
|
||||||
private:
|
private:
|
||||||
QString _username;
|
QString _username;
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
|
QString _lastDomain;
|
||||||
|
glm::vec3 _lastPosition;
|
||||||
QUrl _faceModelURL;
|
QUrl _faceModelURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue