OSDN Git Service

>>800
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 22 May 2004 04:55:53 +0000 (04:55 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 22 May 2004 04:55:53 +0000 (04:55 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1097 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/libkita/access.cpp
kita/src/libkita/access.h
kita/src/libkita/datinfo.cpp
kita/src/part/kitathreadview.cpp

index 84459d9..5302204 100644 (file)
@@ -71,8 +71,7 @@ void Access::writeCacheData( const KURL& url )
         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;
 
@@ -80,7 +79,7 @@ void Access::writeCacheData( const KURL& url )
     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 ;
@@ -91,6 +90,7 @@ QString Access::getupdate()
 
     QString retstr;
     m_threadData = "";
+    m_firstReceive = FALSE;
 
     if ( KURL( m_thread->datURL() ).protocol() != "k2ch" ) {
         KIO::SlaveConfig::self() ->setConfigData( "http",
@@ -109,6 +109,7 @@ QString Access::getupdate()
     // 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" );
     }
@@ -173,7 +174,12 @@ void Access::enter_loop()
 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 );
 }
 
index 1fccaee..9ec2040 100644 (file)
@@ -44,6 +44,7 @@ namespace Kita
         int responseCode();
         static bool deleteLog( const Thread* thread, QWidget* parent );
         static QCString getCacheData( const KURL& url );
+       bool m_firstReceive;
 
     private:
         void writeCacheData( const KURL& url );
@@ -51,9 +52,9 @@ namespace Kita
 
         const Thread* m_thread;
         KIO::Job* m_currentJob;
-        QCString m_threadData;
+        QString m_threadData;
         QString m_header;
-        QCString m_orgData;
+        QString m_orgData;
 
     private slots:
         void slotReceiveThreadData( KIO::Job* job, const QByteArray& data );
index 25e99a3..450b9fe 100644 (file)
@@ -129,9 +129,11 @@ void DatInfo::copyRawDataToBuffer(const QString& rawData)
 {
     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 );
@@ -142,35 +144,26 @@ void DatInfo::copyRawDataToBuffer(const QString& rawData)
        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();
@@ -201,7 +194,7 @@ bool DatInfo::setDat( const QString& line, int num ){
     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 */
 
@@ -265,7 +258,6 @@ void DatInfo::slotReceiveData(const QString& newLine){
     int rescode = m_access->responseCode();
 
     if(rescode != 200 && rescode != 206) return;
-    if(newLine.length() == 1 && newLine.at(0) == '\n') return; /* EOF */
 
     copyRawDataToBuffer(newLine);
 
@@ -284,6 +276,11 @@ void DatInfo::slotFinishLoad(){
     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--;
 }
 
index a67f161..16c9acd 100644 (file)
@@ -508,6 +508,7 @@ void KitaThreadView::slotReloadButton()
        /* update cache */
        /* After updating cache, DatManager will call slotFinishLoad.*/
        if( m_online ){
+           m_domtree->StopParseThread();
            m_showNum = m_domtree->getBottomResNumber() + m_afterShowNum;
            Kita::DatManager::updateCache(m_datURL,this);
            m_threadPart->view()->setFocus();