History

use QString for DataServerClient keys

Stephen Birarda committed 13 years ago

Commit cd504e21 parent 32317762 files · +17 −17Browse files

Showing the changes to interface/src/DataServerClient.cpp (1 of 2 files). Show all

Unified · Split

interface/src/DataServerClient.cpp+10−10
@@ -25,7 +25,7 @@ const char DATA_SERVER_HOSTNAME[] = "data.highfidelity.io"; · 24 unmodified lines
25const unsigned short DATA_SERVER_PORT = 3282;25const unsigned short DATA_SERVER_PORT = 3282;
26const sockaddr_in DATA_SERVER_SOCKET = socketForHostnameAndHostOrderPort(DATA_SERVER_HOSTNAME, DATA_SERVER_PORT);26const sockaddr_in DATA_SERVER_SOCKET = socketForHostnameAndHostOrderPort(DATA_SERVER_HOSTNAME, DATA_SERVER_PORT);
27 27
28void DataServerClient::putValueForKey(const char* key, const char* value) {28void DataServerClient::putValueForKey(const QString& key, const char* value) {
29 QString clientString = Application::getInstance()->getProfile()->getUserString();29 QString clientString = Application::getInstance()->getProfile()->getUserString();
30 if (!clientString.isEmpty()) {30 if (!clientString.isEmpty()) {
31 31
@@ -40,8 +40,8 @@ void DataServerClient::putValueForKey(const char* key, const char* value) { · 8 unmodified lines
40 putPacket[numPacketBytes++] = '\0';40 putPacket[numPacketBytes++] = '\0';
41 41
42 // pack the key, null terminated42 // pack the key, null terminated
43 strcpy((char*) putPacket + numPacketBytes, key);43 strcpy((char*) putPacket + numPacketBytes, key.toLocal8Bit().constData());
44 numPacketBytes += strlen(key);44 numPacketBytes += key.size();
45 putPacket[numPacketBytes++] = '\0';45 putPacket[numPacketBytes++] = '\0';
46 46
47 // pack the value, null terminated47 // pack the value, null terminated
@@ -57,8 +57,8 @@ void DataServerClient::putValueForKey(const char* key, const char* value) { · 9 unmodified lines
57 }57 }
58}58}
59 59
60void DataServerClient::getValueForKeyAndUUID(const char* key, const QUuid &uuid) {60void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uuid) {
61 getValuesForKeysAndUUID(QStringList(QString(key)), uuid);61 getValuesForKeysAndUUID(QStringList(key), uuid);
62}62}
63 63
64void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid) {64void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid) {
@@ -95,8 +95,8 @@ void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, co · 30 unmodified lines
95 }95 }
96}96}
97 97
98void DataServerClient::getClientValueForKey(const char* key) {98void DataServerClient::getClientValueForKey(const QString& key) {
99 getValuesForKeysAndUserString(QStringList(QString(key)), Application::getInstance()->getProfile()->getUserString());99 getValuesForKeysAndUserString(QStringList(key), Application::getInstance()->getProfile()->getUserString());
100}100}
101 101
102void DataServerClient::processConfirmFromDataServer(unsigned char* packetData, int numPacketBytes) {102void DataServerClient::processConfirmFromDataServer(unsigned char* packetData, int numPacketBytes) {
@@ -123,18 +123,18 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 20 unmodified lines
123 // the user string was a username123 // the user string was a username
124 // for now assume this means that it is for our avatar124 // for now assume this means that it is for our avatar
125 125
126 if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL) == 0) {126 if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL.toLocal8Bit().constData()) == 0) {
127 // pull the user's face mesh and set it on the Avatar instance127 // pull the user's face mesh and set it on the Avatar instance
128 128
129 qDebug("Changing user's face model URL to %s\n", dataValueString.toLocal8Bit().constData());129 qDebug("Changing user's face model URL to %s\n", dataValueString.toLocal8Bit().constData());
130 Application::getInstance()->getProfile()->setFaceModelURL(QUrl(dataValueString));130 Application::getInstance()->getProfile()->setFaceModelURL(QUrl(dataValueString));
131 } else if (strcmp(dataKeyPosition, DataServerKey::UUID) == 0) {131 } else if (strcmp(dataKeyPosition, DataServerKey::UUID.toLocal8Bit().constData()) == 0) {
132 // this is the user's UUID - set it on the profile132 // this is the user's UUID - set it on the profile
133 Application::getInstance()->getProfile()->setUUID(dataValueString);133 Application::getInstance()->getProfile()->setUUID(dataValueString);
134 }134 }
135 } else {135 } else {
136 // user string was UUID, find matching avatar and associate data136 // user string was UUID, find matching avatar and associate data
137 if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL) == 0) {137 if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL.toLocal8Bit().constData()) == 0) {
138 NodeList* nodeList = NodeList::getInstance();138 NodeList* nodeList = NodeList::getInstance();
139 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {139 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
140 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {140 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {