Commit 9c222565e170c43685be8354d5657b6158012303

Authored by Matti Virkkunen
1 parent 8e9e45af

Fix connection handling.

linehttptransport.cpp
... ... @@ -137,14 +137,14 @@ void LineHttpTransport::request(std::string method, std::string path, std::strin
137 137 }
138 138  
139 139 void LineHttpTransport::send_next() {
140   - if (in_progress || request_queue.empty())
141   - return;
142   -
143 140 if (state != ConnectionState::CONNECTED) {
144 141 open();
145 142 return;
146 143 }
147 144  
  145 + if (in_progress || request_queue.empty())
  146 + return;
  147 +
148 148 keep_alive = ls_mode;
149 149 status_code_ = -1;
150 150 content_length_ = -1;
... ... @@ -205,7 +205,7 @@ void LineHttpTransport::write_request() {
205 205 request_written += r;
206 206  
207 207 purple_debug_info("line", "Wrote: %d, %d out of %d!\n",
208   - (int)r, (int)request_written, (int)request_data.size());
  208 + (int)r, (int)request_written, (int)request_data.size());
209 209 }
210 210 }
211 211  
... ... @@ -282,6 +282,7 @@ void LineHttpTransport::ssl_read(gint, PurpleInputCondition) {
282 282  
283 283 if (content_length_ >= 0 && response_str.size() >= (size_t)content_length_) {
284 284 purple_input_remove(input_handle);
  285 + input_handle = 0;
285 286  
286 287 if (status_code_ == 403) {
287 288 // Don't try to reconnect because this usually means the user has logged in from
... ...
purpleline_login.cpp
... ... @@ -4,11 +4,13 @@ void PurpleLine::login_start() {
4 4 purple_connection_set_state(conn, PURPLE_CONNECTING);
5 5 purple_connection_update_progress(conn, "Logging in", 0, 3);
6 6  
7   - if (purple_account_get_string(acct, LINE_ACCOUNT_AUTH_TOKEN, NULL)) {
  7 + std::string auth_token = purple_account_get_string(acct, LINE_ACCOUNT_AUTH_TOKEN, "");
  8 +
  9 + if (auth_token != "") {
8 10 // There's a stored authentication token, see if it works
9 11  
10 12 c_out->send_getLastOpRevision();
11   - c_out->send([this]() {
  13 + c_out->send([this, auth_token]() {
12 14 int64_t local_rev;
13 15  
14 16 try {
... ... @@ -31,6 +33,8 @@ void PurpleLine::login_start() {
31 33 throw;
32 34 }
33 35  
  36 + set_auth_token(auth_token);
  37 +
34 38 poller.set_local_rev(local_rev);
35 39  
36 40 // Already got the last op revision, no need to call get_last_op_revision()
... ...