Skip to content

Commit 5ae1fac

Browse files
committed
revert previous [fix non-constraint query]
1 parent d5cfcf0 commit 5ae1fac

File tree

7 files changed

+110
-111
lines changed

7 files changed

+110
-111
lines changed

src/internal/ParseClient.cpp

Lines changed: 97 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -25,145 +25,146 @@ ParseClient::ParseClient() {
2525
}
2626

2727
void ParseClient::begin(const char *applicationId, const char *clientKey) {
28-
Console.println("begin");
29-
30-
// send the info to linux through Bridge
31-
if(applicationId) {
32-
Bridge.put("appId", applicationId);
33-
}
34-
if (clientKey) {
35-
Bridge.put("clientKey", clientKey);
36-
}
28+
Console.println("begin");
29+
30+
// send the info to linux through Bridge
31+
if(applicationId) {
32+
Bridge.put("appId", applicationId);
33+
}
34+
if (clientKey) {
35+
Bridge.put("clientKey", clientKey);
36+
}
3737
}
3838

3939
void ParseClient::setInstallationId(const char *installationId) {
40-
this->installationId = installationId;
41-
if (installationId) {
42-
Bridge.put("installationId", installationId);
43-
} else {
44-
Bridge.put("installationId", "");
45-
}
40+
this->installationId = installationId;
41+
if (installationId) {
42+
Bridge.put("installationId", installationId);
43+
} else {
44+
Bridge.put("installationId", "");
45+
}
4646
}
4747

4848
const char* ParseClient::getInstallationId() {
49-
if (!this->installationId) {
50-
char *buf = new char[37];
49+
if (!this->installationId) {
50+
char *buf = new char[37];
5151

52-
requestClient.begin("parse_request");
53-
requestClient.addParameter("-i");
54-
requestClient.run();
52+
requestClient.begin("parse_request");
53+
requestClient.addParameter("-i");
54+
requestClient.run();
5555
read(&requestClient, buf, 37);
56-
this->installationId = buf;
57-
}
58-
return this->installationId;
56+
this->installationId = buf;
57+
}
58+
return this->installationId;
5959
}
6060

6161
void ParseClient::setSessionToken(const char *sessionToken) {
62-
if ((sessionToken != NULL) && (strlen(sessionToken) > 0 )){
63-
this->sessionToken = sessionToken;
64-
Bridge.put("sessionToken", sessionToken);
65-
} else {
66-
Bridge.put("sessionToken", "");
67-
}
62+
if ((sessionToken != NULL) && (strlen(sessionToken) > 0 )){
63+
this->sessionToken = sessionToken;
64+
Bridge.put("sessionToken", sessionToken);
65+
} else {
66+
Bridge.put("sessionToken", "");
67+
}
6868
}
6969

7070
void ParseClient::clearSessionToken() {
71-
setSessionToken(NULL);
71+
setSessionToken(NULL);
7272
}
7373

7474
const char* ParseClient::getSessionToken() {
75-
if (!this->sessionToken) {
76-
char *buf = new char[33];
77-
78-
requestClient.begin("parse_request");
79-
requestClient.addParameter("-s");
80-
requestClient.run();
81-
read(&requestClient, buf, 33);
82-
this->sessionToken = buf;
83-
}
84-
return this->sessionToken;
75+
if (!this->sessionToken) {
76+
char *buf = new char[33];
77+
78+
requestClient.begin("parse_request");
79+
requestClient.addParameter("-s");
80+
requestClient.run();
81+
read(&requestClient, buf, 33);
82+
this->sessionToken = buf;
83+
}
84+
return this->sessionToken;
8585
}
8686

87-
ParseResponse ParseClient::sendRequest(const char* httpVerb, const char* httpPath, const char* requestBody, bool isQuery) {
88-
return sendRequest(String(httpVerb), String(httpPath), String(requestBody), isQuery);
87+
ParseResponse ParseClient::sendRequest(const char* httpVerb, const char* httpPath, const char* requestBody, const char* urlParams) {
88+
return sendRequest(String(httpVerb), String(httpPath), String(requestBody), String(urlParams));
8989
}
9090

91-
ParseResponse ParseClient::sendRequest(const String& httpVerb, const String& httpPath, const String& requestBody, bool isQuery) {
92-
requestClient.begin("parse_request"); // start a process that launch the "parse_request" command
93-
94-
requestClient.addParameter("-v");
95-
requestClient.addParameter(httpVerb);
96-
requestClient.addParameter("-e");
97-
requestClient.addParameter(httpPath);
98-
if (requestBody != "") {
99-
requestClient.addParameter("-d");
100-
requestClient.addParameter(requestBody);
101-
}
102-
if (isQuery) {
103-
requestClient.addParameter("-p");
91+
ParseResponse ParseClient::sendRequest(const String& httpVerb, const String& httpPath, const String& requestBody, const String& urlParams) {
92+
requestClient.begin("parse_request"); // start a process that launch the "parse_request" command
93+
94+
requestClient.addParameter("-v");
95+
requestClient.addParameter(httpVerb);
96+
requestClient.addParameter("-e");
97+
requestClient.addParameter(httpPath);
98+
if (requestBody != "") {
99+
requestClient.addParameter("-d");
100+
requestClient.addParameter(requestBody);
101+
}
102+
if (urlParams != "") {
103+
requestClient.addParameter("-p");
104+
requestClient.addParameter(urlParams);
104105
requestClient.runAsynchronously();
105-
} else {
106-
requestClient.run(); // Run the process and wait for its termination
107-
}
106+
} else {
107+
requestClient.run(); // Run the process and wait for its termination
108+
}
108109

109-
ParseResponse response(&requestClient);
110-
return response;
110+
ParseResponse response(&requestClient);
111+
return response;
111112
}
112113

113114
bool ParseClient::startPushService() {
114-
pushClient.begin("parse_push"); // start a process that launch the "parse_request" command
115-
pushClient.runAsynchronously();
116-
117-
while(1) {
118-
if(pushClient.available()) {
119-
// read the push starting result
120-
char c = pushClient.read();
121-
while(pushClient.available()) {
122-
pushClient.read();
123-
}
124-
if (c == 's') {
125-
pushClient.write('n'); // send a signal that ready to consume next available push
126-
return true;
127-
} else {
128-
return false;
129-
}
130-
}
131-
}
115+
pushClient.begin("parse_push"); // start a process that launch the "parse_request" command
116+
pushClient.runAsynchronously();
117+
118+
while(1) {
119+
if(pushClient.available()) {
120+
// read the push starting result
121+
char c = pushClient.read();
122+
while(pushClient.available()) {
123+
pushClient.read();
124+
}
125+
if (c == 's') {
126+
pushClient.write('n'); // send a signal that ready to consume next available push
127+
return true;
128+
} else {
129+
return false;
130+
}
131+
}
132+
}
132133
}
133134

134135
ParsePush ParseClient::nextPush() {
135-
ParsePush push(&pushClient);
136-
return push;
136+
ParsePush push(&pushClient);
137+
return push;
137138
}
138139

139140
bool ParseClient::pushAvailable() {
140-
pushClient.write('n'); // send a signal that ready to consume next available push
141-
if(pushClient.available()) {
142-
return 1;
143-
} else {
144-
return 0;
145-
}
141+
pushClient.write('n'); // send a signal that ready to consume next available push
142+
if(pushClient.available()) {
143+
return 1;
144+
} else {
145+
return 0;
146+
}
146147
}
147148

148149
void ParseClient::stopPushService() {
149-
pushClient.close();
150+
pushClient.close();
150151
}
151152

152153
void ParseClient::end() {
153-
stopPushService();
154+
stopPushService();
154155
}
155156

156157
void ParseClient::read(Process* client, char* buf, int len) {
157158
memset(buf, 0, len);
158159
int p = 0;
159-
while(1) {
160-
if(client->available()) {
161-
while (p < (len-1) && client->available()) {
162-
buf[p++] = client->read();
163-
}
164-
break;
165-
}
166-
}
160+
while(1) {
161+
if(client->available()) {
162+
while (p < (len-1) && client->available()) {
163+
buf[p++] = client->read();
164+
}
165+
break;
166+
}
167+
}
167168
}
168169

169170
ParseClient Parse;

src/internal/ParseClient.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,29 +127,27 @@ class ParseClient {
127127
* \param httpVerb - GET/DELETE/PUT/POST
128128
* \param httpPath - the endpoint of REST API e.g. /1/installations
129129
* \param requestBody - http request body in json format, leave it as "" for DELTE/GET requests
130-
* or use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2
131-
* NOTE: isQuery needs to be set as true if you use requestBody as query condition
132-
* \param isQuery - if the request is a query
133-
* \result response of request
130+
* \param urlParams - leave it as "" unless to perform a Parse query,
131+
* use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2
132+
* \result response of request
134133
* NOTE: ParseObjectCreate, ParseObjectUpdate, ParseObjectDelete, ParseGETObject,
135134
* ParseQuery, ParseCloudFunction, ParseTrackEvent can also be used for REST API call
136135
*/
137-
ParseResponse sendRequest(const char* httpVerb, const char* httpPath, const char* requestBody, bool isQuery);
136+
ParseResponse sendRequest(const char* httpVerb, const char* httpPath, const char* requestBody, const char* urlParams);
138137

139138
/*! \fn ParseResponse sendRequest(const String& httpVerb, const String& httpPath, const String& requestBody, const String& urlParams)
140139
* \brief Directly call REST API in Parse.
141140
*
142141
* \param httpVerb - GET/DELETE/PUT/POST
143142
* \param httpPath - the endpoint of REST API e.g. /1/installations
144143
* \param requestBody - http request body in json format, leave it as "" for DELTE/GET requests
145-
* or use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2
146-
* NOTE: isQuery needs to be set as true if you use requestBody as query condition
147-
* \param isQuery - if the request is a query
148-
* \result response of request
144+
* \param urlParams - leave it as "" unless to perform a Parse query,
145+
* use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2
146+
* \result response of request
149147
* NOTE: ParseObjectCreate, ParseObjectUpdate, ParseObjectDelete, ParseGETObject,
150148
* ParseQuery, ParseCloudFunction, ParseTrackEvent can also be used for REST API call
151149
*/
152-
ParseResponse sendRequest(const String& httpVerb, const String& httpPath, const String& requestBody, bool isQuery);
150+
ParseResponse sendRequest(const String& httpVerb, const String& httpPath, const String& requestBody, const String& urlParams);
153151

154152
/*! \fn int startPushService()
155153
* \brief Start the push notifications service.

src/internal/ParseObjectCreate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@ ParseResponse ParseObjectCreate::send() {
9595
if (!isBodySet) {
9696
requestBody += "}";
9797
}
98-
return Parse.sendRequest("POST", httpPath, requestBody, false);
98+
return Parse.sendRequest("POST", httpPath, requestBody, "");
9999
}

src/internal/ParseObjectDelete.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ ParseObjectDelete::ParseObjectDelete() : ParseRequest() {
2626
}
2727

2828
ParseResponse ParseObjectDelete::send() {
29-
return Parse.sendRequest("DELETE", httpPath, "", false);
29+
return Parse.sendRequest("DELETE", httpPath, "", "");
3030
}

src/internal/ParseObjectGet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ ParseObjectGet::ParseObjectGet() : ParseRequest() {
2626
}
2727

2828
ParseResponse ParseObjectGet::send() {
29-
return Parse.sendRequest("GET", httpPath, "", false);
29+
return Parse.sendRequest("GET", httpPath, "", "");
3030
}

src/internal/ParseObjectUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ ParseResponse ParseObjectUpdate::send() {
3131
requestBody += "}";
3232
}
3333

34-
return Parse.sendRequest("PUT", httpPath, requestBody, false);
34+
return Parse.sendRequest("PUT", httpPath, requestBody, "");
3535
}

src/internal/ParseQuery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,6 @@ ParseResponse ParseQuery::send() {
182182
urlParameters += "&keys=";
183183
urlParameters += returnedFields;
184184
}
185-
return Parse.sendRequest("GET", httpPath, urlParameters, true);
185+
return Parse.sendRequest("GET", httpPath, "", urlParameters);
186186
}
187187

0 commit comments

Comments
 (0)