C++ (Qt)QString str;...if (this->socket->waitForReadyRead(30000)){ str.append(this->socket->readAll());}
C++ (Qt)... this->socket->write("RETR " + QString::number(this->listsCount).toLatin1() + "\r\n"); //read last email if (this->socket->waitForReadyRead(30000)) { QString strAllOctets = this->socket->readAll().trimmed(); int intAllOctets = strAllOctets.split(" ").at(1).toInt(); qDebug() << "all octets:" << intAllOctets; QString strReply, strAppend; forever { if (this->socket->waitForReadyRead(5000)) { strAppend = this->socket->readAll(); strReply.append(strAppend); //добавление полученного фрагмента к сумме предыдущих intAllOctets -= strAppend.length(); if (intAllOctets <= 0) break; } }...
C++ (Qt)qDebug() << "all octets:" << intAllOctets;
C++ (Qt) socket->write("RETR 3\r\n"); QString m_messages; while(socket->waitForReadyRead(5000)) m_messages.append(socket->readAll()); qDebug() << m_messages; //show all letter's text
int POP3::connect_pop3(){ if (POP3_State!=NONE_State) return 0; count_command=0; Pop3Socket->disconnectFromHost(); POP3_State=CONNECT_State; connect(Pop3Socket,SIGNAL(readyRead()),SLOT(socketReadyRead())); connect(this,SIGNAL(ReadMailComplete()),SLOT(MailParse())); connect(this,SIGNAL(Response_Ready()),SLOT(ParsePOP3Command())); connect(this,SIGNAL(Next()),SLOT(time_out())); if (type_socket==1) { connect(Pop3Socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>))); Pop3Socket->connectToHostEncrypted(mail_server,port); } else { Pop3Socket->connectToHost(mail_server,port,QIODevice::ReadWrite); } return 0;}void POP3::socketReadyRead(){ if ( !Pop3Socket->canReadLine() ) return; QByteArray temp = Pop3Socket->readAll(); //qDebug()<<temp; mail_RAW.append(temp); if (POP3_State==RETR_State || POP3_State==TOP_State) { if( mail_RAW.endsWith("\r\n.\r\n")) { emit ReadMailComplete(); } } else if (POP3_State==UIDL_State_All || POP3_State==LIST_State_All) { if( mail_RAW.endsWith("\r\n.\r\n")) { emit Response_Ready(); } } else { if ( mail_RAW.endsWith("\r\n") ) { emit Response_Ready(); } }}