summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gmrequest.c32
-rw-r--r--src/gmrequest.h4
-rw-r--r--src/ui/documentwidget.c12
3 files changed, 25 insertions, 23 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index a83a7666..bad45604 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -105,7 +105,7 @@ void deserialize_GmResponse(iGmResponse *d, iStream *ins) {
105 105
106/*----------------------------------------------------------------------------------------------*/ 106/*----------------------------------------------------------------------------------------------*/
107 107
108static const int bodyTimeout_GmRequest_ = 3000; /* ms */ 108//static const int bodyTimeout_GmRequest_ = 3000; /* ms */
109 109
110enum iGmRequestState { 110enum iGmRequestState {
111 initialized_GmRequestState, 111 initialized_GmRequestState,
@@ -123,15 +123,15 @@ struct Impl_GmRequest {
123 iString url; 123 iString url;
124 iTlsRequest * req; 124 iTlsRequest * req;
125 iGmResponse resp; 125 iGmResponse resp;
126 uint32_t timeoutId; /* in case server doesn't close the connection */ 126 //uint32_t timeoutId; /* in case server doesn't close the connection */
127 iAudience * updated; 127 iAudience * updated;
128 iAudience * timeout; 128// iAudience * timeout;
129 iAudience * finished; 129 iAudience * finished;
130}; 130};
131 131
132iDefineObjectConstructionArgs(GmRequest, (iGmCerts *certs), certs) 132iDefineObjectConstructionArgs(GmRequest, (iGmCerts *certs), certs)
133iDefineAudienceGetter(GmRequest, updated) 133iDefineAudienceGetter(GmRequest, updated)
134iDefineAudienceGetter(GmRequest, timeout) 134//iDefineAudienceGetter(GmRequest, timeout)
135iDefineAudienceGetter(GmRequest, finished) 135iDefineAudienceGetter(GmRequest, finished)
136 136
137void init_GmRequest(iGmRequest *d, iGmCerts *certs) { 137void init_GmRequest(iGmRequest *d, iGmCerts *certs) {
@@ -139,11 +139,11 @@ void init_GmRequest(iGmRequest *d, iGmCerts *certs) {
139 init_GmResponse(&d->resp); 139 init_GmResponse(&d->resp);
140 init_String(&d->url); 140 init_String(&d->url);
141 d->certs = certs; 141 d->certs = certs;
142 d->timeoutId = 0; 142// d->timeoutId = 0;
143 d->req = NULL; 143 d->req = NULL;
144 d->state = initialized_GmRequestState; 144 d->state = initialized_GmRequestState;
145 d->updated = NULL; 145 d->updated = NULL;
146 d->timeout = NULL; 146// d->timeout = NULL;
147 d->finished = NULL; 147 d->finished = NULL;
148} 148}
149 149
@@ -153,9 +153,9 @@ void deinit_GmRequest(iGmRequest *d) {
153 iDisconnectObject(TlsRequest, d->req, finished, d); 153 iDisconnectObject(TlsRequest, d->req, finished, d);
154 } 154 }
155 lock_Mutex(&d->mutex); 155 lock_Mutex(&d->mutex);
156 if (d->timeoutId) { 156// if (d->timeoutId) {
157 SDL_RemoveTimer(d->timeoutId); 157// SDL_RemoveTimer(d->timeoutId);
158 } 158// }
159 if (!isFinished_GmRequest(d)) { 159 if (!isFinished_GmRequest(d)) {
160 unlock_Mutex(&d->mutex); 160 unlock_Mutex(&d->mutex);
161 cancel_TlsRequest(d->req); 161 cancel_TlsRequest(d->req);
@@ -166,7 +166,7 @@ void deinit_GmRequest(iGmRequest *d) {
166 } 166 }
167 iRelease(d->req); 167 iRelease(d->req);
168 d->req = NULL; 168 d->req = NULL;
169 delete_Audience(d->timeout); 169// delete_Audience(d->timeout);
170 delete_Audience(d->finished); 170 delete_Audience(d->finished);
171 delete_Audience(d->updated); 171 delete_Audience(d->updated);
172 deinit_GmResponse(&d->resp); 172 deinit_GmResponse(&d->resp);
@@ -179,6 +179,7 @@ void setUrl_GmRequest(iGmRequest *d, const iString *url) {
179 urlEncodeSpaces_String(&d->url); 179 urlEncodeSpaces_String(&d->url);
180} 180}
181 181
182#if 0
182static uint32_t timedOutWhileReceivingBody_GmRequest_(uint32_t interval, void *obj) { 183static uint32_t timedOutWhileReceivingBody_GmRequest_(uint32_t interval, void *obj) {
183 /* Note: Called from SDL's timer thread. */ 184 /* Note: Called from SDL's timer thread. */
184 iGmRequest *d = obj; 185 iGmRequest *d = obj;
@@ -187,11 +188,13 @@ static uint32_t timedOutWhileReceivingBody_GmRequest_(uint32_t interval, void *o
187 iUnused(interval); 188 iUnused(interval);
188 return 0; 189 return 0;
189} 190}
191#endif
190 192
191void cancel_GmRequest(iGmRequest *d) { 193void cancel_GmRequest(iGmRequest *d) {
192 cancel_TlsRequest(d->req); 194 cancel_TlsRequest(d->req);
193} 195}
194 196
197#if 0
195static void restartTimeout_GmRequest_(iGmRequest *d) { 198static void restartTimeout_GmRequest_(iGmRequest *d) {
196 /* Note: `d` is currently locked. */ 199 /* Note: `d` is currently locked. */
197 if (d->timeoutId) { 200 if (d->timeoutId) {
@@ -199,6 +202,7 @@ static void restartTimeout_GmRequest_(iGmRequest *d) {
199 } 202 }
200 d->timeoutId = SDL_AddTimer(bodyTimeout_GmRequest_, timedOutWhileReceivingBody_GmRequest_, d); 203 d->timeoutId = SDL_AddTimer(bodyTimeout_GmRequest_, timedOutWhileReceivingBody_GmRequest_, d);
201} 204}
205#endif
202 206
203static void checkServerCertificate_GmRequest_(iGmRequest *d) { 207static void checkServerCertificate_GmRequest_(iGmRequest *d) {
204 const iTlsCertificate *cert = serverCertificate_TlsRequest(d->req); 208 const iTlsCertificate *cert = serverCertificate_TlsRequest(d->req);
@@ -272,12 +276,12 @@ static void readIncoming_GmRequest_(iAnyObject *obj) {
272 notifyUpdate = iTrue; 276 notifyUpdate = iTrue;
273 /* Start a timeout for the remainder of the response, in case the connection 277 /* Start a timeout for the remainder of the response, in case the connection
274 remains open. */ 278 remains open. */
275 restartTimeout_GmRequest_(d); 279// restartTimeout_GmRequest_(d);
276 } 280 }
277 } 281 }
278 else if (d->state == receivingBody_GmRequestState) { 282 else if (d->state == receivingBody_GmRequestState) {
279 append_Block(&d->resp.body, data); 283 append_Block(&d->resp.body, data);
280 restartTimeout_GmRequest_(d); 284// restartTimeout_GmRequest_(d);
281 notifyUpdate = iTrue; 285 notifyUpdate = iTrue;
282 } 286 }
283 initCurrent_Time(&d->resp.when); 287 initCurrent_Time(&d->resp.when);
@@ -300,8 +304,8 @@ static void requestFinished_GmRequest_(iAnyObject *obj) {
300 delete_Block(data); 304 delete_Block(data);
301 initCurrent_Time(&d->resp.when); 305 initCurrent_Time(&d->resp.when);
302 } 306 }
303 SDL_RemoveTimer(d->timeoutId); 307// SDL_RemoveTimer(d->timeoutId);
304 d->timeoutId = 0; 308// d->timeoutId = 0;
305 d->state = (status_TlsRequest(d->req) == error_TlsRequestStatus ? failure_GmRequestState 309 d->state = (status_TlsRequest(d->req) == error_TlsRequestStatus ? failure_GmRequestState
306 : finished_GmRequestState); 310 : finished_GmRequestState);
307 if (d->state == failure_GmRequestState) { 311 if (d->state == failure_GmRequestState) {
diff --git a/src/gmrequest.h b/src/gmrequest.h
index 4d413430..3fe9b7da 100644
--- a/src/gmrequest.h
+++ b/src/gmrequest.h
@@ -58,10 +58,10 @@ iDeclareClass(GmRequest)
58iDeclareObjectConstructionArgs(GmRequest, iGmCerts *) 58iDeclareObjectConstructionArgs(GmRequest, iGmCerts *)
59 59
60iDeclareNotifyFunc(GmRequest, Updated) 60iDeclareNotifyFunc(GmRequest, Updated)
61iDeclareNotifyFunc(GmRequest, Timeout) 61//iDeclareNotifyFunc(GmRequest, Timeout)
62iDeclareNotifyFunc(GmRequest, Finished) 62iDeclareNotifyFunc(GmRequest, Finished)
63iDeclareAudienceGetter(GmRequest, updated) 63iDeclareAudienceGetter(GmRequest, updated)
64iDeclareAudienceGetter(GmRequest, timeout) 64//iDeclareAudienceGetter(GmRequest, timeout)
65iDeclareAudienceGetter(GmRequest, finished) 65iDeclareAudienceGetter(GmRequest, finished)
66 66
67void setUrl_GmRequest (iGmRequest *, const iString *url); 67void setUrl_GmRequest (iGmRequest *, const iString *url);
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 193f2099..ec79dd18 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -255,10 +255,12 @@ static void requestUpdated_DocumentWidget_(iAnyObject *obj) {
255 } 255 }
256} 256}
257 257
258#if 0
258static void requestTimedOut_DocumentWidget_(iAnyObject *obj) { 259static void requestTimedOut_DocumentWidget_(iAnyObject *obj) {
259 iDocumentWidget *d = obj; 260 iDocumentWidget *d = obj;
260 postCommandf_App("document.request.timeout doc:%p request:%p", d, d->request); 261 postCommandf_App("document.request.timeout doc:%p request:%p", d, d->request);
261} 262}
263#endif
262 264
263static void requestFinished_DocumentWidget_(iAnyObject *obj) { 265static void requestFinished_DocumentWidget_(iAnyObject *obj) {
264 iDocumentWidget *d = obj; 266 iDocumentWidget *d = obj;
@@ -867,7 +869,7 @@ static void fetch_DocumentWidget_(iDocumentWidget *d) {
867 d->request = new_GmRequest(certs_App()); 869 d->request = new_GmRequest(certs_App());
868 setUrl_GmRequest(d->request, d->mod.url); 870 setUrl_GmRequest(d->request, d->mod.url);
869 iConnect(GmRequest, d->request, updated, d, requestUpdated_DocumentWidget_); 871 iConnect(GmRequest, d->request, updated, d, requestUpdated_DocumentWidget_);
870 iConnect(GmRequest, d->request, timeout, d, requestTimedOut_DocumentWidget_); 872// iConnect(GmRequest, d->request, timeout, d, requestTimedOut_DocumentWidget_);
871 iConnect(GmRequest, d->request, finished, d, requestFinished_DocumentWidget_); 873 iConnect(GmRequest, d->request, finished, d, requestFinished_DocumentWidget_);
872 submit_GmRequest(d->request); 874 submit_GmRequest(d->request);
873} 875}
@@ -1369,17 +1371,13 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1369 postCommandf_App("document.changed url:%s", cstr_String(d->mod.url)); 1371 postCommandf_App("document.changed url:%s", cstr_String(d->mod.url));
1370 return iFalse; 1372 return iFalse;
1371 } 1373 }
1374#if 0
1372 else if (equal_Command(cmd, "document.request.timeout") && 1375 else if (equal_Command(cmd, "document.request.timeout") &&
1373 pointerLabel_Command(cmd, "request") == d->request) { 1376 pointerLabel_Command(cmd, "request") == d->request) {
1374 cancel_GmRequest(d->request); 1377 cancel_GmRequest(d->request);
1375 return iFalse; 1378 return iFalse;
1376 } 1379 }
1377 /* 1380#endif
1378 else if (equal_Command(cmd, "document.request.cancelled") && document_Command(cmd) == d) {
1379 postCommand_App("navigate.back");
1380 return iFalse;
1381 }
1382 */
1383 else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) { 1381 else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) {
1384 return handleMediaCommand_DocumentWidget_(d, cmd); 1382 return handleMediaCommand_DocumentWidget_(d, cmd);
1385 } 1383 }