| 168 | } |
| 169 | |
| 170 | void |
| 171 | RMSViewTab::processSocketData(void) |
| 172 | { |
| 173 | char c; |
| 174 | bool firstTime = this->data.size() == 0; |
| 175 | |
| 176 | while (this->socket->bytesAvailable() > 0) { |
| 177 | if (this->socket->read(&c, 1) < 1) { |
| 178 | this->disconnectSocket(); |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | if (c == '\n') { |
| 183 | this->parseLine(); |
| 184 | this->line.clear(); |
| 185 | } else if (isprint(c)) { |
| 186 | this->line += c; |
| 187 | if (this->line.size() >= MAX_LINE_SIZE) { |
| 188 | this->line.clear(); |
| 189 | this->disconnect(); |
| 190 | QMessageBox::critical( |
| 191 | this, |
| 192 | "Max line size exceeded", |
| 193 | "Remote peer attempted to flood us. Preventively disconnected"); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | if (firstTime && this->data.size() > 0) { |
| 199 | qint64 width = this->ui->waveform->getVerticalAxisWidth(); |
| 200 | this->ui->waveform->zoomHorizontal( |
| 201 | -width, |
| 202 | static_cast<qint64>(this->ui->waveform->size().width()) - width); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | void |
| 207 | RMSViewTab::disconnectSocket(void) |