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
2525 const unsigned short DATA_SERVER_PORT = 3282;
2626 const sockaddr_in DATA_SERVER_SOCKET = socketForHostnameAndHostOrderPort(DATA_SERVER_HOSTNAME, DATA_SERVER_PORT);
2727
28−void DataServerClient::putValueForKey(const char* key, const char* value) {
28+void DataServerClient::putValueForKey(const QString& key, const char* value) {
2929 QString clientString = Application::getInstance()->getProfile()->getUserString();
3030 if (!clientString.isEmpty()) {
3131
@@ -40,8 +40,8 @@ void DataServerClient::putValueForKey(const char* key, const char* value) { · 8 unmodified lines
4040 putPacket[numPacketBytes++] = '\0';
4141
4242 // pack the key, null terminated
43− strcpy((char*) putPacket + numPacketBytes, key);
44− numPacketBytes += strlen(key);
43+ strcpy((char*) putPacket + numPacketBytes, key.toLocal8Bit().constData());
44+ numPacketBytes += key.size();
4545 putPacket[numPacketBytes++] = '\0';
4646
4747 // pack the value, null terminated
@@ -57,8 +57,8 @@ void DataServerClient::putValueForKey(const char* key, const char* value) { · 9 unmodified lines
5757 }
5858 }
5959
60−void DataServerClient::getValueForKeyAndUUID(const char* key, const QUuid &uuid) {
61− getValuesForKeysAndUUID(QStringList(QString(key)), uuid);
60+void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uuid) {
61+ getValuesForKeysAndUUID(QStringList(key), uuid);
6262 }
6363
6464 void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid) {
@@ -95,8 +95,8 @@ void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, co · 30 unmodified lines
9595 }
9696 }
9797
98−void DataServerClient::getClientValueForKey(const char* key) {
99− getValuesForKeysAndUserString(QStringList(QString(key)), Application::getInstance()->getProfile()->getUserString());
98+void DataServerClient::getClientValueForKey(const QString& key) {
99+ getValuesForKeysAndUserString(QStringList(key), Application::getInstance()->getProfile()->getUserString());
100100 }
101101
102102 void DataServerClient::processConfirmFromDataServer(unsigned char* packetData, int numPacketBytes) {
@@ -123,18 +123,18 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 20 unmodified lines
123123 // the user string was a username
124124 // for now assume this means that it is for our avatar
125125
126− if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL) == 0) {
126+ if (strcmp(dataKeyPosition, DataServerKey::FaceMeshURL.toLocal8Bit().constData()) == 0) {
127127 // pull the user's face mesh and set it on the Avatar instance
128128
129129 qDebug("Changing user's face model URL to %s\n", dataValueString.toLocal8Bit().constData());
130130 Application::getInstance()->getProfile()->setFaceModelURL(QUrl(dataValueString));
131− } else if (strcmp(dataKeyPosition, DataServerKey::UUID) == 0) {
131+ } else if (strcmp(dataKeyPosition, DataServerKey::UUID.toLocal8Bit().constData()) == 0) {
132132 // this is the user's UUID - set it on the profile
133133 Application::getInstance()->getProfile()->setUUID(dataValueString);
134134 }
135135 } else {
136136 // 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) {
138138 NodeList* nodeList = NodeList::getInstance();
139139 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
140140 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {