replace http request implement for bbsmenuretriever.
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * bbsmenuretriever.c |
3 | 3 | * |
4 | - * Copyright (c) 2009-2010 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -34,8 +34,9 @@ | ||
34 | 34 | |
35 | 35 | #include "bbsmenuretriever.h" |
36 | 36 | |
37 | -#include "retriever.h" | |
38 | 37 | #include "bbsmenucache.h" |
38 | +#include <http/http_typedef.h> | |
39 | +#include <http/http_connector.h> | |
39 | 40 | |
40 | 41 | #ifdef BCHANL_CONFIG_DEBUG |
41 | 42 | # define DP(arg) printf arg |
@@ -46,10 +47,12 @@ | ||
46 | 47 | #endif |
47 | 48 | |
48 | 49 | struct bbsmnretriever_t_ { |
49 | - retriever_t *retr; | |
50 | + http_connector_t *connector; | |
51 | + ID endpoint; | |
52 | + HTTP_STATUSCODE status; | |
50 | 53 | }; |
51 | 54 | |
52 | -EXPORT bbsmnretriever_t* bbsmnretriever_new() | |
55 | +EXPORT bbsmnretriever_t* bbsmnretriever_new(http_connector_t *connector) | |
53 | 56 | { |
54 | 57 | bbsmnretriever_t *retriever; |
55 | 58 |
@@ -57,11 +60,9 @@ | ||
57 | 60 | if (retriever == NULL) { |
58 | 61 | return NULL; |
59 | 62 | } |
60 | - retriever->retr = retriever_new(); | |
61 | - if (retriever->retr == NULL) { | |
62 | - free(retriever); | |
63 | - return NULL; | |
64 | - } | |
63 | + retriever->connector = connector; | |
64 | + retriever->endpoint = -1; | |
65 | + retriever->status = 0; | |
65 | 66 | |
66 | 67 | return retriever; |
67 | 68 | } |
@@ -68,34 +69,12 @@ | ||
68 | 69 | |
69 | 70 | EXPORT VOID bbsmnretriever_delete(bbsmnretriever_t *retriever) |
70 | 71 | { |
71 | - retriever_delete(retriever->retr); | |
72 | + if (retriever->endpoint > 0) { | |
73 | + http_connector_deleteendpoint(retriever->connector, retriever->endpoint); | |
74 | + } | |
72 | 75 | free(retriever); |
73 | 76 | } |
74 | 77 | |
75 | -#define SO_ERR_SEND_LEN(sockID, str, len) \ | |
76 | - err = so_send(sockID, (str), (len), 0); \ | |
77 | - if(err < 0){ \ | |
78 | - return err; \ | |
79 | - } | |
80 | - | |
81 | -#define SO_ERR_SEND(sockID, str) SO_ERR_SEND_LEN(sockID, (str), strlen((str))) | |
82 | - | |
83 | -LOCAL W bbsmnretriever_sendheader(W sock) | |
84 | -{ | |
85 | - W err; | |
86 | - | |
87 | - SO_ERR_SEND(sock, "GET /bbsmenu.html HTTP/1.1\r\n"); | |
88 | - SO_ERR_SEND(sock, "Accept-Encoding: gzip\r\n"); | |
89 | - SO_ERR_SEND(sock, "Host: menu.2ch.net\r\n"); | |
90 | - SO_ERR_SEND(sock, "Accept: */*\r\n"); | |
91 | - SO_ERR_SEND(sock, "Referer: http://menu.2ch.net/\r\n"); | |
92 | - SO_ERR_SEND(sock, "Accept-Language: ja\r\n"); | |
93 | - SO_ERR_SEND(sock, "User-Agent: Monazilla/1.00 (bchanl/0.101)\r\n"); | |
94 | - SO_ERR_SEND(sock, "Connection: close\r\n"); | |
95 | - SO_ERR_SEND(sock, "\r\n"); | |
96 | - | |
97 | - return 0; | |
98 | -} | |
99 | 78 | /* from http://www.monazilla.org/index.php?e=196 */ |
100 | 79 | #if 0 |
101 | 80 | " |
@@ -112,62 +91,80 @@ | ||
112 | 91 | |
113 | 92 | EXPORT W bbsmnretriever_sendrequest(bbsmnretriever_t *retriever, bbsmncache_t *cache) |
114 | 93 | { |
115 | - W sock, err, ret = -1, len, status; | |
116 | - UB *bin, *host = "menu.2ch.net"; | |
94 | + UB host[] = "menu.2ch.net"; | |
117 | 95 | |
118 | - retriever_clearbuffer(retriever->retr); | |
119 | - | |
120 | - err = retriever_gethost(retriever->retr, host); | |
121 | - if (err < 0) { | |
122 | - return err; | |
96 | + if (retriever->endpoint > 0) { | |
97 | + DP(("bbsmnretriever_sendrequest: requesting\n")); | |
98 | + return -1; | |
123 | 99 | } |
124 | - sock = retriver_connectsocket(retriever->retr); | |
125 | - if (sock < 0) { | |
126 | - return sock; | |
127 | - } | |
128 | 100 | |
129 | - err = bbsmnretriever_sendheader(sock); | |
130 | - if (err < 0) { | |
131 | - so_close(sock); | |
132 | - return err; | |
101 | + retriever->endpoint = http_connector_createendpoint(retriever->connector, host, strlen(host), 80, HTTP_METHOD_GET); | |
102 | + if (retriever->endpoint < 0) { | |
103 | + DP_ER("http_connector_createendpoint error", retriever->endpoint); | |
104 | + return -1; | |
133 | 105 | } |
134 | 106 | |
135 | - err = retriever_recieve(retriever->retr, sock); | |
136 | - if (err < 0) { | |
137 | - so_close(sock); | |
138 | - return err; | |
139 | - } | |
107 | + return 0; | |
108 | +} | |
140 | 109 | |
141 | - err = retriever_parsehttpresponse(retriever->retr); | |
142 | - if (err < 0) { | |
143 | - so_close(sock); | |
144 | - return err; | |
110 | +EXPORT Bool bbsmnretriever_iswaitingendpoint(bbsmnretriever_t *retriever, ID endpoint) | |
111 | +{ | |
112 | + if (retriever->endpoint == endpoint) { | |
113 | + return True; | |
145 | 114 | } |
146 | - retriever_dumpheader(retriever->retr); | |
115 | + return False; | |
116 | +} | |
147 | 117 | |
148 | - err = retriever_decompress(retriever->retr); | |
149 | - if (err < 0) { | |
150 | - so_close(sock); | |
151 | - return err; | |
152 | - } | |
118 | +LOCAL UB path[] = "/bbsmenu.html"; | |
119 | +LOCAL UB header[] = | |
120 | +"Accept: */*\r\n" | |
121 | +"Referer: http://menu.2ch.net/\r\n" | |
122 | +"Accept-Language: ja\r\n" | |
123 | +"User-Agent: Monazilla/1.00\r\n"; | |
153 | 124 | |
154 | - status = retriever_parse_response_status(retriever->retr); | |
155 | - if (status == 200) { | |
156 | - bin = retriever_getbody(retriever->retr); | |
157 | - len = retriever_getbodylength(retriever->retr); | |
158 | - bbsmncache_cleardata(cache); | |
159 | - bbsmncache_appenddata(cache, bin, len); | |
125 | +EXPORT W bbsmnretriever_recievehttpevent(bbsmnretriever_t *retriever, bbsmncache_t *cache, http_connector_event *hevent) | |
126 | +{ | |
127 | + http_connector_t *connector = retriever->connector; | |
160 | 128 | |
161 | - bin = retriever_getheader(retriever->retr); | |
162 | - len = retriever_getheaderlength(retriever->retr); | |
163 | - bbsmncache_updatelatestheader(cache, bin, len); | |
129 | + if (retriever->endpoint <= 0) { | |
130 | + return -1; | |
131 | + } | |
164 | 132 | |
165 | - ret = BBSMNRETRIEVER_REQUEST_ALLRELOAD; | |
133 | + if (hevent->type == HTTP_CONNECTOR_EVENTTYPE_SEND) { | |
134 | + http_connector_sendrequestline(connector, hevent->endpoint, path, strlen(path)); | |
135 | + http_connector_sendheader(connector, hevent->endpoint, header, strlen(header)); | |
136 | + http_connector_sendheaderend(connector, hevent->endpoint); | |
137 | + http_connector_sendmessagebody(connector, hevent->endpoint, NULL, 0); | |
138 | + http_connector_sendmessagebodyend(connector, hevent->endpoint); | |
139 | + } else if (hevent->type == HTTP_CONNECTOR_EVENTTYPE_RECEIVE_STATUSLINE) { | |
140 | + DP(("HTTP_CONNECTOR_EVENTTYPE_RECEIVE_STATUSLINE\n")); | |
141 | + DP((" status = %d\n", hevent->data.receive_statusline.statuscode)); | |
142 | + retriever->status = hevent->data.receive_statusline.statuscode; | |
143 | + } else if (hevent->type == HTTP_CONNECTOR_EVENTTYPE_RECEIVE_HEADER) { | |
144 | +#ifdef BCHANL_CONFIG_DEBUG | |
145 | + { | |
146 | + W i = 0; | |
147 | + for (i = 0; i < hevent->data.receive_header.len; i++) { | |
148 | + printf("%c", hevent->data.receive_header.bin[i]); | |
149 | + } | |
150 | + } | |
151 | +#endif | |
152 | + } else if (hevent->type == HTTP_CONNECTOR_EVENTTYPE_RECEIVE_HEADER_END) { | |
153 | + } else if (hevent->type == HTTP_CONNECTOR_EVENTTYPE_RECEIVE_MESSAGEBODY) { | |
154 | + if (retriever->status == HTTP_STATUSCODE_200_OK) { | |
155 | + bbsmncache_appenddata(cache, hevent->data.receive_messagebody.bin, hevent->data.receive_messagebody.len); | |
156 | + } | |
157 | + } else if (hevent->type == HTTP_CONNECTOR_EVENTTYPE_RECEIVE_MESSAGEBODY_END) { | |
158 | + http_connector_deleteendpoint(connector, hevent->endpoint); | |
159 | + retriever->endpoint = -1; | |
160 | + return BBSMNRETRIEVER_REQUEST_ALLRELOAD; | |
161 | + } else if (hevent->type == HTTP_CONNECTOR_EVENTTYPE_ERROR) { | |
162 | + http_connector_deleteendpoint(connector, hevent->endpoint); | |
163 | + retriever->endpoint = -1; | |
164 | + } else { | |
165 | + /* error */ | |
166 | + return -1; | |
166 | 167 | } |
167 | 168 | |
168 | - so_close(sock); | |
169 | - | |
170 | - retriever_clearbuffer(retriever->retr); | |
171 | - | |
172 | - return ret; | |
169 | + return BBSMNRETRIEVER_REQUEST_WAITNEXT; | |
173 | 170 | } |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /* |
2 | 2 | * bbsmenuretriever.h |
3 | 3 | * |
4 | - * Copyright (c) 2009 project bchan | |
4 | + * Copyright (c) 2009-2012 project bchan | |
5 | 5 | * |
6 | 6 | * This software is provided 'as-is', without any express or implied |
7 | 7 | * warranty. In no event will the authors be held liable for any damages |
@@ -26,6 +26,7 @@ | ||
26 | 26 | |
27 | 27 | #include <basic.h> |
28 | 28 | #include "bbsmenucache.h" |
29 | +#include <http/http_connector.h> | |
29 | 30 | |
30 | 31 | #ifndef __BBSMENURETREIEVER_H__ |
31 | 32 | #define __BBSMENURETREIEVER_H__ |
@@ -32,11 +33,14 @@ | ||
32 | 33 | |
33 | 34 | typedef struct bbsmnretriever_t_ bbsmnretriever_t; |
34 | 35 | |
35 | -IMPORT bbsmnretriever_t* bbsmnretriever_new(); | |
36 | +IMPORT bbsmnretriever_t* bbsmnretriever_new(http_connector_t *connector); | |
36 | 37 | IMPORT VOID bbsmnretriever_delete(bbsmnretriever_t *retriever); |
37 | 38 | IMPORT W bbsmnretriever_sendrequest(bbsmnretriever_t *retriever, bbsmncache_t *cache); |
39 | +IMPORT Bool bbsmnretriever_iswaitingendpoint(bbsmnretriever_t *retriever, ID endpoint); | |
40 | +IMPORT W bbsmnretriever_recievehttpevent(bbsmnretriever_t *retriever, bbsmncache_t *cache, http_connector_event *hevent); | |
38 | 41 | |
39 | 42 | #define BBSMNRETRIEVER_REQUEST_NOT_MODIFIED 0 |
40 | 43 | #define BBSMNRETRIEVER_REQUEST_ALLRELOAD 1 |
44 | +#define BBSMNRETRIEVER_REQUEST_WAITNEXT 2 | |
41 | 45 | |
42 | 46 | #endif |
@@ -58,6 +58,8 @@ | ||
58 | 58 | #include "bchanl_menus.h" |
59 | 59 | #include "bchanl_panels.h" |
60 | 60 | |
61 | +#include <http/http_connector.h> | |
62 | + | |
61 | 63 | #ifdef BCHANL_CONFIG_DEBUG |
62 | 64 | # define DP(arg) printf arg |
63 | 65 | # define DP_ER(msg, err) printf("%s (%d/%x)\n", msg, err>>16, err) |
@@ -144,9 +146,11 @@ | ||
144 | 146 | TC *category_extbbs; |
145 | 147 | }; |
146 | 148 | |
149 | +#define BCHANL_NETWORK_FLAG_WAITHTTPEVENT 0x00000001 | |
150 | + | |
147 | 151 | struct bchanl_t_ { |
148 | 152 | W taskid; |
149 | - W mbfid; | |
153 | + W flgid; /* for reduce TMOUT message sending. */ | |
150 | 154 | |
151 | 155 | bchanl_mainmenu_t mainmenu; |
152 | 156 | VID vid; |
@@ -154,6 +158,8 @@ | ||
154 | 158 | |
155 | 159 | bchanl_hmistate_t hmistate; |
156 | 160 | |
161 | + http_connector_t *connector; | |
162 | + | |
157 | 163 | sbjtretriever_t *retriever; |
158 | 164 | |
159 | 165 | bchanl_subjecthash_t *subjecthash; |
@@ -659,7 +665,7 @@ | ||
659 | 665 | } |
660 | 666 | } |
661 | 667 | |
662 | -LOCAL W bchanl_bbsmenu_initialize(bchanl_bbsmenu_t *bchanl, GID gid, bchanl_subjecthash_t *subjecthash, LINK *storage) | |
668 | +LOCAL W bchanl_bbsmenu_initialize(bchanl_bbsmenu_t *bchanl, GID gid, bchanl_subjecthash_t *subjecthash, LINK *storage, http_connector_t *connector) | |
663 | 669 | { |
664 | 670 | bbsmnretriever_t *retriever; |
665 | 671 | bbsmncache_t *cache; |
@@ -675,7 +681,7 @@ | ||
675 | 681 | if (cache == NULL) { |
676 | 682 | goto error_cache; |
677 | 683 | } |
678 | - retriever = bbsmnretriever_new(); | |
684 | + retriever = bbsmnretriever_new(connector); | |
679 | 685 | if (retriever == NULL) { |
680 | 686 | goto error_retriever; |
681 | 687 | } |
@@ -1007,42 +1013,80 @@ | ||
1007 | 1013 | |
1008 | 1014 | #define BCHANL_MESSAGE_RETRIEVER_RELAYOUT 1 |
1009 | 1015 | #define BCHANL_MESSAGE_RETRIEVER_ERROR -1 |
1016 | +#define BCHANL_MESSAGE_HTTP_EVENT 2 | |
1010 | 1017 | |
1011 | -LOCAL VOID bchanl_retriever_task(W arg) | |
1018 | +LOCAL Bool bchanl_bbsmenu_httpevent(bchanl_bbsmenu_t *bchanl, http_connector_event *hevent) | |
1012 | 1019 | { |
1020 | + Bool ok; | |
1021 | + W err; | |
1022 | + | |
1023 | + ok = bbsmnretriever_iswaitingendpoint(bchanl->retriever, hevent->endpoint); | |
1024 | + if (ok == False) { | |
1025 | + return False; | |
1026 | + } | |
1027 | + err = bbsmnretriever_recievehttpevent(bchanl->retriever, bchanl->cache, hevent); | |
1028 | + | |
1029 | + switch (err) { | |
1030 | + case BBSMNRETRIEVER_REQUEST_ALLRELOAD: | |
1031 | + req_tmg(0, BCHANL_MESSAGE_RETRIEVER_RELAYOUT); | |
1032 | + break; | |
1033 | + case BBSMNRETRIEVER_REQUEST_WAITNEXT: | |
1034 | + break; | |
1035 | + default: | |
1036 | + req_tmg(0, BCHANL_MESSAGE_RETRIEVER_ERROR); | |
1037 | + DP_ER("bbsmnretriever_recievehttpevent", err); | |
1038 | + break; | |
1039 | + } | |
1040 | + | |
1041 | + return True; | |
1042 | +} | |
1043 | + | |
1044 | +LOCAL VOID bchanl_http_task(W arg) | |
1045 | +{ | |
1013 | 1046 | bchanl_t *bchanl; |
1047 | + http_connector_t *connector; | |
1014 | 1048 | bbsmnretriever_t *retr; |
1015 | 1049 | bbsmncache_t *cache; |
1016 | - W msg,err; | |
1050 | + W err; | |
1017 | 1051 | |
1018 | 1052 | bchanl = (bchanl_t*)arg; |
1053 | + connector = bchanl->connector; | |
1019 | 1054 | retr = bchanl->bbsmenu.retriever; |
1020 | 1055 | cache = bchanl->bbsmenu.cache; |
1021 | 1056 | |
1022 | 1057 | for (;;) { |
1023 | - DP(("before rcv_mbf %d\n", bchanl->mbfid)); | |
1024 | - err = rcv_mbf(bchanl->mbfid, (VP)&msg, T_FOREVER); | |
1025 | - DP_ER("rcv_mbf error:",err); | |
1026 | - if (err != 4) { | |
1027 | - continue; | |
1028 | - } | |
1029 | - | |
1030 | - err = bbsmnretriever_sendrequest(retr, cache); | |
1031 | - | |
1032 | - switch (err) { | |
1033 | - case BBSMNRETRIEVER_REQUEST_ALLRELOAD: | |
1034 | - req_tmg(0, BCHANL_MESSAGE_RETRIEVER_RELAYOUT); | |
1035 | - break; | |
1036 | - default: | |
1058 | + err = http_connector_waitconnection(connector, T_FOREVER); | |
1059 | + if (err < 0) { | |
1060 | + DP_ER("http_connector_waitconnection", err); | |
1037 | 1061 | req_tmg(0, BCHANL_MESSAGE_RETRIEVER_ERROR); |
1038 | - DP_ER("bbsmnretreiver_request error",err); | |
1039 | 1062 | break; |
1040 | 1063 | } |
1064 | + | |
1065 | + err = wai_flg(bchanl->flgid, BCHANL_NETWORK_FLAG_WAITHTTPEVENT, WF_AND, T_FOREVER); | |
1066 | + if (err < 0) { | |
1067 | + DP_ER("wai_flg", err); | |
1068 | + } | |
1069 | + req_tmg(0, BCHANL_MESSAGE_HTTP_EVENT); | |
1041 | 1070 | } |
1042 | 1071 | |
1043 | 1072 | ext_tsk(); |
1044 | 1073 | } |
1045 | 1074 | |
1075 | +LOCAL VOID bchanl_handle_httpevent(bchanl_t *bchanl) | |
1076 | +{ | |
1077 | + W err; | |
1078 | + http_connector_event hevent; | |
1079 | + | |
1080 | + set_flg(bchanl->flgid, BCHANL_NETWORK_FLAG_WAITHTTPEVENT); | |
1081 | + | |
1082 | + err = http_connector_getevent(bchanl->connector, &hevent); | |
1083 | + if (err < 0) { | |
1084 | + return; | |
1085 | + } | |
1086 | + | |
1087 | + bchanl_bbsmenu_httpevent(&bchanl->bbsmenu, &hevent); | |
1088 | +} | |
1089 | + | |
1046 | 1090 | LOCAL W bchanl_prepare_network(bchanl_t *bchanl) |
1047 | 1091 | { |
1048 | 1092 | if (bchanl->retriever == NULL) { |
@@ -1049,18 +1093,18 @@ | ||
1049 | 1093 | return 0; |
1050 | 1094 | } |
1051 | 1095 | |
1052 | - bchanl->mbfid = cre_mbf(sizeof(W), sizeof(W), DELEXIT); | |
1053 | - if (bchanl->mbfid < 0) { | |
1054 | - DP_ER("error cre_mbf:", bchanl->mbfid); | |
1055 | - return -1; | |
1056 | - } | |
1057 | - bchanl->taskid = cre_tsk(bchanl_retriever_task, -1, (W)bchanl); | |
1096 | + bchanl->taskid = cre_tsk(bchanl_http_task, -1, (W)bchanl); | |
1058 | 1097 | if (bchanl->taskid < 0) { |
1059 | - del_mbf(bchanl->mbfid); | |
1060 | - bchanl->mbfid = -1; | |
1061 | 1098 | DP_ER("error cre_tsk:", bchanl->taskid); |
1062 | 1099 | return -1; |
1063 | 1100 | } |
1101 | + bchanl->flgid = cre_flg(0, DELEXIT); | |
1102 | + if (bchanl->flgid < 0) { | |
1103 | + ter_tsk(bchanl->taskid); | |
1104 | + bchanl->taskid = -1; | |
1105 | + DP_ER("error cre_flg:", bchanl->flgid); | |
1106 | + return -1; | |
1107 | + } | |
1064 | 1108 | |
1065 | 1109 | return 0; |
1066 | 1110 | } |
@@ -1067,11 +1111,11 @@ | ||
1067 | 1111 | |
1068 | 1112 | LOCAL W bchanl_networkrequest_bbsmenu(bchanl_t *bchanl) |
1069 | 1113 | { |
1070 | - W msg = 1, err; | |
1114 | + W err; | |
1071 | 1115 | static UW lastrequest = 0; |
1072 | 1116 | UW etime; |
1073 | 1117 | |
1074 | - if (bchanl->mbfid < 0) { | |
1118 | + if (bchanl->flgid < 0) { | |
1075 | 1119 | return 0; |
1076 | 1120 | } |
1077 | 1121 |
@@ -1085,11 +1129,15 @@ | ||
1085 | 1129 | } |
1086 | 1130 | lastrequest = etime; |
1087 | 1131 | |
1088 | - err = snd_mbf(bchanl->mbfid, &msg, sizeof(W), T_FOREVER); | |
1132 | + bchanl_hmistate_updateptrstyle(&bchanl->hmistate, PS_BUSY); | |
1133 | + | |
1134 | + err = bbsmnretriever_sendrequest(bchanl->bbsmenu.retriever, bchanl->bbsmenu.cache); | |
1089 | 1135 | if (err < 0) { |
1090 | - DP_ER("snd_mbf error:", err); | |
1136 | + DP_ER("bbsmnretriever_sendrequest error:", err); | |
1137 | + bchanl_hmistate_updateptrstyle(&bchanl->hmistate, PS_SELECT); | |
1091 | 1138 | return err; |
1092 | 1139 | } |
1140 | + set_flg(bchanl->flgid, BCHANL_NETWORK_FLAG_WAITHTTPEVENT); | |
1093 | 1141 | |
1094 | 1142 | bchanl_hmistate_updateptrstyle(&bchanl->hmistate, PS_BUSY); |
1095 | 1143 | pdsp_msg(bchanl->hmistate.msg_retr_bbsmenu); |
@@ -1111,6 +1159,7 @@ | ||
1111 | 1159 | GID gid; |
1112 | 1160 | RECT w_work; |
1113 | 1161 | PNT p0 = {450, 0}; |
1162 | + http_connector_t *connector; | |
1114 | 1163 | sbjtretriever_t *retriever; |
1115 | 1164 | bchanlhmi_t *hmi; |
1116 | 1165 | bchanl_subjecthash_t *subjecthash; |
@@ -1127,6 +1176,12 @@ | ||
1127 | 1176 | bgpat = &bgpat0; |
1128 | 1177 | } |
1129 | 1178 | |
1179 | + connector = http_connector_new(); | |
1180 | + if (connector == NULL) { | |
1181 | + DP_ER("http_connector_new error", 0); | |
1182 | + goto error_http_connector; | |
1183 | + } | |
1184 | + | |
1130 | 1185 | retriever = sbjtretriever_new(); |
1131 | 1186 | if (retriever == NULL) { |
1132 | 1187 | DP_ER("sbjtretriever_new error", 0); |
@@ -1171,7 +1226,7 @@ | ||
1171 | 1226 | DP_ER("bchanlhmi_newexternalbbswindow", 0); |
1172 | 1227 | goto error_externalbbswindow; |
1173 | 1228 | } |
1174 | - err = bchanl_bbsmenu_initialize(&(bchanl->bbsmenu), gid, subjecthash, storage); | |
1229 | + err = bchanl_bbsmenu_initialize(&(bchanl->bbsmenu), gid, subjecthash, storage, connector); | |
1175 | 1230 | if (err < 0) { |
1176 | 1231 | DP_ER("bchanl_bbsmenu_initialize error", err); |
1177 | 1232 | goto error_bbsmenu; |
@@ -1193,6 +1248,7 @@ | ||
1193 | 1248 | bbsmndraw_setviewrect(bchanl->bbsmenu.draw, 0, 0, w_work.c.right, w_work.c.bottom); |
1194 | 1249 | bbsmenuwindow_setworkrect(bbsmenuwindow, 0, 0, w_work.c.right, w_work.c.bottom); |
1195 | 1250 | |
1251 | + bchanl->connector = connector; | |
1196 | 1252 | bchanl->retriever = retriever; |
1197 | 1253 | bchanl->subjecthash = subjecthash; |
1198 | 1254 |
@@ -1232,6 +1288,8 @@ | ||
1232 | 1288 | error_bchanlhmi: |
1233 | 1289 | sbjtretriever_delete(retriever); |
1234 | 1290 | error_retriever: |
1291 | + http_connector_delete(connector); | |
1292 | +error_http_connector: | |
1235 | 1293 | return -1; /* TODO */ |
1236 | 1294 | } |
1237 | 1295 |
@@ -1253,6 +1311,7 @@ | ||
1253 | 1311 | bchanlhmi_deletesubjectwindow(bchanl->hmi, bchanl->subjectwindow); |
1254 | 1312 | bchanlhmi_delete(bchanl->hmi); |
1255 | 1313 | sbjtretriever_delete(bchanl->retriever); |
1314 | + http_connector_delete(bchanl->connector); | |
1256 | 1315 | |
1257 | 1316 | ext_prc(0); |
1258 | 1317 | } |
@@ -1803,6 +1862,9 @@ | ||
1803 | 1862 | bchanl_hmistate_updateptrstyle(&bchanl->hmistate, PS_SELECT); |
1804 | 1863 | pdsp_msg(NULL); |
1805 | 1864 | break; |
1865 | + case BCHANL_MESSAGE_HTTP_EVENT: | |
1866 | + bchanl_handle_httpevent(bchanl); | |
1867 | + break; | |
1806 | 1868 | } |
1807 | 1869 | } |
1808 | 1870 |