OSDN Git Service

move method.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 9 Jun 2004 14:05:26 +0000 (14:05 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 9 Jun 2004 14:05:26 +0000 (14:05 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1155 56b19765-1e22-0410-a548-a0f45d66c51a

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

index e66da43..059640b 100644 (file)
@@ -161,11 +161,87 @@ void Access::slotThreadResult( KIO::Job* job )
 
     if ( responseCode() != 200 && responseCode() != 206 ) retstr = QString::null;
     if ( Kita::boardType( m_url.url() ) == Board_MachiBBS ) {
+        // TODO: need to refactoring.
+        parse_machiBBS();
+        KURL url = m_url;
+        url.setProtocol( "k2ch" );
+        writeCacheData( url );
         emit receiveData( m_threadData );
     }
     emit finishLoad();
 }
 
+void Access::parse_machiBBS()
+{
+    QString ret;
+    QStringList lines = QStringList::split( "\n", m_threadData );
+    // pattern 1 (tokyo,kanagawa,...)
+    QRegExp regexp( "<dt>(.*) .*<font color=\"#......\"><b> (.*) </b></font> .* (..../../..).* (..:..:..) ID:(.*)<br><dd>(.*)" );
+    QRegExp regexp2( "<dt>(.*) .*<a href=\"mailto:(.*)\"><b> (.*) </B></a> .* (..../../..).* (..:..:..) ID:(.*)<br><dd>(.*)" );
+    
+    // pattern 2 (hokkaido,...)
+    QRegExp regexp3( "<dt>(.*) .*<font color=\"#......\"><b> (.*) </b></font> .* (..../../..).* (..:..:..) ID:(.*)<font size=.>\\[ .*" );
+    QRegExp regexp4( " \\]</font><br><dd>(.*)" );
+    QRegExp regexp5( "<dt>(.*) .*<a href=\"mailto:(.*)\"><b> (.*) </B></a> .* (..../../..).* (..:..:..) ID:(.*)<font size=.>\\[ .*" );
+    for ( QStringList::iterator it = lines.begin(); it != lines.end(); ++it ) {
+        QString line = (*it);
+        if ( regexp.search( line ) != -1 ) {
+            int num = regexp.cap( 1 ).toInt();
+            QString name = regexp.cap( 2 );
+            QString date = regexp.cap( 3 );
+            QString time = regexp.cap( 4 );
+            QString id = regexp.cap( 5 );
+            QString message = regexp.cap( 6 );
+            QString datStr = name + "<><>" + date + " " + time + " ID:" + id
+            + "<>" + message + "<>\n";
+            ret += datStr;
+        } else if ( regexp2.search( line ) != -1 ) {
+            int num = regexp2.cap( 1 ).toInt();
+            QString mail = regexp2.cap( 2 );
+            QString name = regexp2.cap( 3 );
+            QString date = regexp2.cap( 4 );
+            QString time = regexp2.cap( 5 );
+            QString id = regexp2.cap( 6 );
+            QString message = regexp2.cap( 7 );
+            QString datStr = name + "<>" + mail + "<>" + date + " " + time + " ID:" + id
+            + "<>" + message + "<>\n";
+            ret += datStr;
+        } else if ( regexp3.search( line ) != -1 ) {
+            ++it;
+            if ( it == lines.end() ) break;
+            QString nextLine = (*it);
+            if ( regexp4.search( nextLine ) != -1 ) {
+                int num = regexp3.cap( 1 ).toInt();
+                QString name = regexp3.cap( 2 );
+                QString date = regexp3.cap( 3 );
+                QString time = regexp3.cap( 4 );
+                QString id = regexp3.cap( 5 );
+                QString message = regexp4.cap( 1 );
+                QString datStr = name + "<><>" + date + " " + time + " ID:" + id
+                + "<>" + message + "<>\n";
+                ret += datStr;
+            }
+        } else if ( regexp5.search( line ) != -1 ) {
+            ++it;
+            if ( it == lines.end() ) break;
+            QString nextLine = (*it);
+            if ( regexp4.search( nextLine ) != -1 ) {
+                int num = regexp5.cap( 1 ).toInt();
+                QString mail = regexp5.cap( 2 );
+                QString name = regexp5.cap( 3 );
+                QString date = regexp5.cap( 4 );
+                QString time = regexp5.cap( 5 );
+                QString id = regexp5.cap( 6 );
+                QString message = regexp4.cap( 1 );
+                QString datStr = name + "<>" + mail + "<>" + date + " " + time + " ID:" + id
+                + "<>" + message + "<>\n";
+                ret += datStr;
+            }
+        }
+    }
+    m_threadData = ret;
+}
+
 // from netaccess.cpp
 void qt_enter_modal( QWidget* widget );
 void qt_leave_modal( QWidget* widget );
index 70fde5c..288acf4 100644 (file)
@@ -49,6 +49,7 @@ namespace Kita
     private:
         void writeCacheData( const KURL& url );
         void enter_loop();
+        void parse_machiBBS();
 
         const KURL m_url;
         KIO::Job* m_currentJob;
index 2f7a258..7cb34e8 100644 (file)
@@ -124,78 +124,6 @@ void DatInfo::deleteAccessJob()
     }
 }
 
-void DatInfo::copyRawDataToBuffer_MachiBBS( const QString& rawData )
-{
-    QString data = Kita::ParseMisc::qcpToUnicode( rawData );
-    QStringList lines = QStringList::split( "\n", data );
-    // pattern 1 (tokyo,kanagawa,...)
-    QRegExp regexp( "<dt>(.*) .*<font color=\"#......\"><b> (.*) </b></font> .* (..../../..).* (..:..:..) ID:(.*)<br><dd>(.*)" );
-    QRegExp regexp2( "<dt>(.*) .*<a href=\"mailto:(.*)\"><b> (.*) </B></a> .* (..../../..).* (..:..:..) ID:(.*)<br><dd>(.*)" );
-    
-    // pattern 2 (hokkaido,...)
-    QRegExp regexp3( "<dt>(.*) .*<font color=\"#......\"><b> (.*) </b></font> .* (..../../..).* (..:..:..) ID:(.*)<font size=.>\\[ .*" );
-    QRegExp regexp4( " \\]</font><br><dd>(.*)" );
-    QRegExp regexp5( "<dt>(.*) .*<a href=\"mailto:(.*)\"><b> (.*) </B></a> .* (..../../..).* (..:..:..) ID:(.*)<font size=.>\\[ .*" );
-    for ( QStringList::iterator it = lines.begin(); it != lines.end(); ++it ) {
-        QString line = (*it);
-        if ( regexp.search( line ) != -1 ) {
-            int num = regexp.cap( 1 ).toInt();
-            QString name = regexp.cap( 2 );
-            QString date = regexp.cap( 3 );
-            QString time = regexp.cap( 4 );
-            QString id = regexp.cap( 5 );
-            QString message = regexp.cap( 6 );
-            QString datStr = name + "<><>" + date + " " + time + " ID:" + id
-            + "<>" + message + "<>";
-            setDat( datStr, num );
-        } else if ( regexp2.search( line ) != -1 ) {
-            int num = regexp2.cap( 1 ).toInt();
-            QString mail = regexp2.cap( 2 );
-            QString name = regexp2.cap( 3 );
-            QString date = regexp2.cap( 4 );
-            QString time = regexp2.cap( 5 );
-            QString id = regexp2.cap( 6 );
-            QString message = regexp2.cap( 7 );
-            QString datStr = name + "<>" + mail + "<>" + date + " " + time + " ID:" + id
-            + "<>" + message + "<>";
-            setDat( datStr, num );
-        } else if ( regexp3.search( line ) != -1 ) {
-            ++it;
-            if ( it == lines.end() ) break;
-            QString nextLine = (*it);
-            if ( regexp4.search( nextLine ) != -1 ) {
-                int num = regexp3.cap( 1 ).toInt();
-                QString name = regexp3.cap( 2 );
-                QString date = regexp3.cap( 3 );
-                QString time = regexp3.cap( 4 );
-                QString id = regexp3.cap( 5 );
-                QString message = regexp4.cap( 1 );
-                QString datStr = name + "<><>" + date + " " + time + " ID:" + id
-                + "<>" + message + "<>";
-                setDat( datStr, num );
-            }
-        } else if ( regexp5.search( line ) != -1 ) {
-            ++it;
-            if ( it == lines.end() ) break;
-            QString nextLine = (*it);
-            if ( regexp4.search( nextLine ) != -1 ) {
-                int num = regexp5.cap( 1 ).toInt();
-                QString mail = regexp5.cap( 2 );
-                QString name = regexp5.cap( 3 );
-                QString date = regexp5.cap( 4 );
-                QString time = regexp5.cap( 5 );
-                QString id = regexp5.cap( 6 );
-                QString message = regexp4.cap( 1 );
-                QString datStr = name + "<>" + mail + "<>" + date + " " + time + " ID:" + id
-                + "<>" + message + "<>";
-                setDat( datStr, num );
-            }
-        }
-    }
-    m_thread->setResNum( m_maxNum );
-    KitaThreadInfo::setReadNum( m_url.prettyURL(), m_maxNum );
-}
-
 /* copy raw lines to buffer */
 
 /*  !! NOTICE!!
@@ -204,12 +132,15 @@ void DatInfo::copyRawDataToBuffer_MachiBBS( const QString& rawData )
    to copy the last line to buffer.      */ /* private */
 void DatInfo::copyRawDataToBuffer(const QString& rawData)
 {
-    if ( Kita::boardType( m_url.url() ) == Board_MachiBBS ) {
-        copyRawDataToBuffer_MachiBBS( rawData );
-        return;
-    }
     QStringList linelist;
     int basenum = m_maxNum + 1;
+    
+    // hack for machiBBS
+    if ( Kita::boardType( m_url.url() ) == Board_MachiBBS && m_lastLine == QString::null && m_access->responseCode() == 200 ) {
+        basenum = 1;
+        m_maxNum = 0;
+    }
+    
     bool endIsLF = FALSE;
     if ( rawData != QString::null ){
 
@@ -251,6 +182,7 @@ void DatInfo::copyRawDataToBuffer(const QString& rawData)
          it != linelist.end(); ++it, ++basenum ) {
        if((*it) != QString::null){
            QString line = ParseMisc::qcpToUnicode((*it));
+            qDebug("basenum = %d", basenum);
            setDat(line,basenum);
        }
     }
index fc64123..a3bf322 100644 (file)
@@ -207,7 +207,6 @@ class DatInfo : public QObject
 
        /* copy data */
        void copyRawDataToBuffer(const QString& rawData);
-       void copyRawDataToBuffer_MachiBBS(const QString& rawData);
        bool setDat( const QString& line, int num );
        
        /* HTML data */