From e08f4d2eba25c2e52a1e69f4f5d6265fa54712cc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 21 Jan 2014 13:13:57 -0800 Subject: [PATCH] more DataServerClient API tweaks --- interface/src/Application.cpp | 4 ++-- interface/src/Menu.cpp | 14 ++++++------- interface/src/avatar/Profile.cpp | 16 +++++++-------- libraries/shared/src/DataServerClient.cpp | 24 +++++++++++------------ libraries/shared/src/DataServerClient.h | 10 +++++----- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8b0fcc9b09..ac243bfa3e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1854,8 +1854,8 @@ void Application::init() { if (!_profile.getUsername().isEmpty()) { // we have a username for this avatar, ask the data-server for the mesh URL for this avatar - DataServerClient::getClientValueForKey(DataServerKey::FaceMeshURL, _profile.getUsername(), &_profile); - DataServerClient::getClientValueForKey(DataServerKey::SkeletonURL, _profile.getUsername(), &_profile); + DataServerClient::getValueForKeyAndUserString(DataServerKey::FaceMeshURL, _profile.getUserString(), &_profile); + DataServerClient::getValueForKeyAndUserString(DataServerKey::SkeletonURL, _profile.getUserString(), &_profile); } // Set up VoxelSystem after loading preferences so we can get the desired max voxel count diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index a4fcd975ca..3e70426d09 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -830,9 +830,9 @@ void Menu::editPreferences() { applicationInstance->getProfile()->setFaceModelURL(faceModelURL); // send the new face mesh URL to the data-server (if we have a client UUID) - DataServerClient::putValueForKeyAndUsername(DataServerKey::FaceMeshURL, - faceModelURL.toString().toLocal8Bit().constData(), - applicationInstance->getProfile()->getUsername()); + DataServerClient::putValueForKeyAndUserString(DataServerKey::FaceMeshURL, + faceModelURL.toString().toLocal8Bit().constData(), + applicationInstance->getProfile()->getUserString()); } QUrl skeletonModelURL(skeletonURLEdit->text()); @@ -842,9 +842,9 @@ void Menu::editPreferences() { applicationInstance->getProfile()->setSkeletonModelURL(skeletonModelURL); // send the new skeleton model URL to the data-server (if we have a client UUID) - DataServerClient::putValueForKeyAndUsername(DataServerKey::SkeletonURL, - skeletonModelURL.toString().toLocal8Bit().constData(), - applicationInstance->getProfile()->getUsername()); + DataServerClient::putValueForKeyAndUserString(DataServerKey::SkeletonURL, + skeletonModelURL.toString().toLocal8Bit().constData(), + applicationInstance->getProfile()->getUserString()); } applicationInstance->getAvatar()->getHead().setPupilDilation(pupilDilation->value() / (float)pupilDilation->maximum()); @@ -963,7 +963,7 @@ void Menu::goToUser() { int dialogReturn = userDialog.exec(); if (dialogReturn == QDialog::Accepted && !userDialog.textValue().isEmpty()) { // there's a username entered by the user, make a request to the data-server - DataServerClient::getValuesForKeysAndUsername( + DataServerClient::getValuesForKeysAndUserString( QStringList() << DataServerKey::Domain << DataServerKey::Position << DataServerKey::Orientation, userDialog.textValue(), Application::getInstance()->getProfile()); } diff --git a/interface/src/avatar/Profile.cpp b/interface/src/avatar/Profile.cpp index f701505e73..82427babc0 100644 --- a/interface/src/avatar/Profile.cpp +++ b/interface/src/avatar/Profile.cpp @@ -27,9 +27,9 @@ Profile::Profile(const QString &username) : setUsername(username); // we've been given a new username, ask the data-server for profile - DataServerClient::getClientValueForKey(DataServerKey::UUID, username, this); - DataServerClient::getClientValueForKey(DataServerKey::FaceMeshURL, username, this); - DataServerClient::getClientValueForKey(DataServerKey::SkeletonURL, username, this); + DataServerClient::getValueForKeyAndUserString(DataServerKey::UUID, getUserString(), this); + DataServerClient::getValueForKeyAndUserString(DataServerKey::FaceMeshURL, getUserString(), this); + DataServerClient::getValueForKeyAndUserString(DataServerKey::SkeletonURL, getUserString(), this); // send our current domain server to the data-server updateDomain(NodeList::getInstance()->getDomainHostname()); @@ -70,7 +70,7 @@ void Profile::updateDomain(const QString& domain) { _lastDomain = domain; // send the changed domain to the data-server - DataServerClient::putValueForKeyAndUsername(DataServerKey::Domain, domain, _username); + DataServerClient::putValueForKeyAndUserString(DataServerKey::Domain, domain, getUserString()); } } @@ -99,8 +99,8 @@ void Profile::updatePosition(const glm::vec3 position) { gettimeofday(&lastPositionSend, NULL); // send the changed position to the data-server - DataServerClient::putValueForKeyAndUsername(DataServerKey::Position, - QString(createByteArray(position)), _username); + DataServerClient::putValueForKeyAndUserString(DataServerKey::Position, + QString(createByteArray(position)), getUserString()); } } } @@ -116,8 +116,8 @@ void Profile::updateOrientation(const glm::quat& orientation) { uint64_t now = usecTimestampNow(); if (now - _lastOrientationSend >= DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS && glm::distance(_lastOrientation, eulerAngles) >= DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES) { - DataServerClient::putValueForKeyAndUsername(DataServerKey::Orientation, QString(createByteArray(eulerAngles)), - _username); + DataServerClient::putValueForKeyAndUserString(DataServerKey::Orientation, QString(createByteArray(eulerAngles)), + getUserString()); _lastOrientation = eulerAngles; _lastOrientationSend = now; diff --git a/libraries/shared/src/DataServerClient.cpp b/libraries/shared/src/DataServerClient.cpp index b16739c9bf..2eb8fcc1f0 100644 --- a/libraries/shared/src/DataServerClient.cpp +++ b/libraries/shared/src/DataServerClient.cpp @@ -29,7 +29,7 @@ const HifiSockAddr& DataServerClient::dataServerSockAddr() { return dsSockAddr; } -void DataServerClient::putValueForKeyAndUsername(const QString& key, const QString& value, const QString& clientIdentifier) { +void DataServerClient::putValueForKeyAndUserString(const QString& key, const QString& value, const QString& userString) { unsigned char putPacket[MAX_PACKET_SIZE]; // setup the header for this packet @@ -40,8 +40,8 @@ void DataServerClient::putValueForKeyAndUsername(const QString& key, const QStri numPacketBytes += sizeof(_sequenceNumber); // pack the client UUID, null terminated - memcpy(putPacket + numPacketBytes, qPrintable(clientIdentifier), clientIdentifier.toLocal8Bit().size()); - numPacketBytes += clientIdentifier.toLocal8Bit().size(); + memcpy(putPacket + numPacketBytes, qPrintable(userString), userString.size()); + numPacketBytes += userString.size(); putPacket[numPacketBytes++] = '\0'; // pack a 1 to designate that we are putting a single value @@ -70,7 +70,7 @@ void DataServerClient::putValueForKeyAndUsername(const QString& key, const QStri } void DataServerClient::putValueForKeyAndUUID(const QString& key, const QString& value, const QUuid& uuid) { - putValueForKeyAndUsername(key, value, uuidStringWithoutCurlyBraces(uuid)); + putValueForKeyAndUserString(key, value, uuidStringWithoutCurlyBraces(uuid)); } void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uuid, DataServerCallbackObject* callbackObject) { @@ -79,13 +79,13 @@ void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uu void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid, DataServerCallbackObject* callbackObject) { if (!uuid.isNull()) { - getValuesForKeysAndUsername(keys, uuidStringWithoutCurlyBraces(uuid), callbackObject); + getValuesForKeysAndUserString(keys, uuidStringWithoutCurlyBraces(uuid), callbackObject); } } -void DataServerClient::getValuesForKeysAndUsername(const QStringList& keys, const QString& clientIdentifier, +void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, const QString& userString, DataServerCallbackObject* callbackObject) { - if (!clientIdentifier.isEmpty() && keys.size() <= UCHAR_MAX) { + if (!userString.isEmpty() && keys.size() <= UCHAR_MAX) { unsigned char getPacket[MAX_PACKET_SIZE]; // setup the header for this packet @@ -96,8 +96,8 @@ void DataServerClient::getValuesForKeysAndUsername(const QStringList& keys, cons numPacketBytes += sizeof(_sequenceNumber); // pack the user string (could be username or UUID string), null-terminate - memcpy(getPacket + numPacketBytes, clientIdentifier.toLocal8Bit().constData(), clientIdentifier.size()); - numPacketBytes += clientIdentifier.size(); + memcpy(getPacket + numPacketBytes, qPrintable(userString), userString.size()); + numPacketBytes += userString.size(); getPacket[numPacketBytes++] = '\0'; // pack one byte to designate the number of keys @@ -122,9 +122,9 @@ void DataServerClient::getValuesForKeysAndUsername(const QStringList& keys, cons } } -void DataServerClient::getClientValueForKey(const QString& key, const QString& clientIdentifier, - DataServerCallbackObject* callbackObject) { - getValuesForKeysAndUsername(QStringList(key), clientIdentifier, callbackObject); +void DataServerClient::getValueForKeyAndUserString(const QString& key, const QString& userString, + DataServerCallbackObject* callbackObject) { + getValuesForKeysAndUserString(QStringList(key), userString, callbackObject); } void DataServerClient::processConfirmFromDataServer(unsigned char* packetData) { diff --git a/libraries/shared/src/DataServerClient.h b/libraries/shared/src/DataServerClient.h index 11ceb8c42c..0ce9355f4b 100644 --- a/libraries/shared/src/DataServerClient.h +++ b/libraries/shared/src/DataServerClient.h @@ -26,15 +26,15 @@ class DataServerClient { public: static const HifiSockAddr& dataServerSockAddr(); - static void putValueForKeyAndUsername(const QString& key, const QString& value, const QString& clientIdentifier); + static void putValueForKeyAndUserString(const QString& key, const QString& value, const QString& userString); static void putValueForKeyAndUUID(const QString& key, const QString& value, const QUuid& uuid); - static void getClientValueForKey(const QString& key, const QString& _clientIdentifer, - DataServerCallbackObject* callbackObject); + static void getValueForKeyAndUserString(const QString& key, const QString& userString, + DataServerCallbackObject* callbackObject); static void getValueForKeyAndUUID(const QString& key, const QUuid& uuid, DataServerCallbackObject* callbackObject); static void getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid, DataServerCallbackObject* callbackObject); - static void getValuesForKeysAndUsername(const QStringList& keys, const QString& clientIdentifier, - DataServerCallbackObject* callbackObject); + static void getValuesForKeysAndUserString(const QStringList& keys, const QString& userString, + DataServerCallbackObject* callbackObject); static void processMessageFromDataServer(unsigned char* packetData, int numPacketBytes);