m_threadData = m_orgData;
return ;
} else if ( ! m_orgData.isNull() && responseCode() == 206 ) {
- QCString orgData = QCString( m_orgData, m_orgData.length() );
- m_threadData = orgData + m_threadData;
+ m_threadData = m_orgData + m_threadData;
}
m_orgData = m_threadData;
FILE *fs = fopen( QFile::encodeName( cachePath ), "w" );
if ( !fs ) return ;
- fwrite( m_threadData, m_threadData.size(), 1, fs );
+ fwrite( m_threadData, m_threadData.length(), 1, fs );
fclose( fs );
return ;
QString retstr;
m_threadData = "";
+ m_firstReceive = FALSE;
if ( KURL( m_thread->datURL() ).protocol() != "k2ch" ) {
KIO::SlaveConfig::self() ->setConfigData( "http",
// use 'HTTP-Headers' metadata.
job->addMetaData( "PropagateHttpHeader", "true" );
if ( ! m_orgData.isNull() ) {
+ m_firstReceive = TRUE; /* remove first char. see also slotReceiveThreadData() */
job->addMetaData( "resume", QString::number( m_orgData.length() - 1 ) );
job->addMetaData( "AllowCompressedPage", "false" );
}
void Access::slotReceiveThreadData( KIO::Job*, const QByteArray& data )
{
QString cstr( data );
- m_threadData.append( cstr );
+ /* If this is the first call at resumption, remove LF at head. */
+ if(m_firstReceive) {
+ cstr = cstr.mid(1);
+ }
+ m_firstReceive = FALSE;
+ m_threadData += cstr ;
emit receiveData( cstr );
}
{
QStringList linelist;
int basenum = m_maxNum + 1;
-
+ bool endIsLF = FALSE;
if ( rawData != QString::null ){
+ if(rawData.at(rawData.length()-1) == '\n') endIsLF = TRUE;
+
/* split the raw data */
m_lastLine += rawData;
linelist = QStringList::split( "\n", m_lastLine );
if( lastit != linelist.end() ){
m_lastLine = (*lastit);
linelist.remove(lastit);
+
+ /* If the last char of rawData is LF, then
+ add LF to m_lastLine, because LF was
+ removed by above QStringList::split(). */
+ if(endIsLF) m_lastLine += '\n';
}
else m_lastLine = QString::null;
}
else{ /* If rawData == null, then copy the last line */
- if( m_lastLine != QString::null ){
-
- /* The last line is broken. ( maybe due to
- having canceled loading. ) */
- if ( m_lastLine.contains( "<>" ) != 4 ) {
-
- /* Truncate the last line here. The reason is:
-
- job->addMetaData( "resume", QString::number( m_orgData.length() - 1 ) );
- ~~~~~~~~~~~~~~~~~~~~~~
- in Access::getupdate().
+ if ( m_lastLine != QString::null
+ && m_lastLine.contains( "<>" ) == 4
+ && m_lastLine.at(m_lastLine.length()-1) == '\n' ) {
- */
- m_lastLine.truncate(m_lastLine.length()-1);
-
- }
- else{
-
+ m_lastLine.truncate(m_lastLine.length()-1);/* remove LF */
linelist += m_lastLine;
m_lastLine = QString::null;
}
}
- }
/* copy lines to buffer */
for ( QStringList::iterator it = linelist.begin();
resdat.set = TRUE;
resdat.linestr = line;
if(m_maxNum < num) m_maxNum = num;
- m_rawData += line;
+ m_rawData += line + '\n';
if(num == 1) parseDat ( num ); /* to get subject */
int rescode = m_access->responseCode();
if(rescode != 200 && rescode != 206) return;
- if(newLine.length() == 1 && newLine.at(0) == '\n') return; /* EOF */
copyRawDataToBuffer(newLine);
m_kokoyonNum = KitaThreadInfo::readNum( m_url.prettyURL() );
m_nowLoading = FALSE;
emit finishLoad();
+
+ /* disconnect signals */
+ disconnect( SIGNAL( receiveData() ));
+ disconnect( SIGNAL( finishLoad() ) );
+
if(m_lock) m_lock--;
}