OSDN Git Service

refactoring.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Mon, 30 Aug 2004 14:05:39 +0000 (14:05 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Mon, 30 Aug 2004 14:05:39 +0000 (14:05 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1343 56b19765-1e22-0410-a548-a0f45d66c51a

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

index 02e06c0..45565c7 100644 (file)
@@ -141,7 +141,7 @@ void Access::slotThreadResult( KIO::Job* job )
     if ( !m_invalidDataReceived && m_threadData.length() ) {
         if ( Kita::boardType( m_datURL.url() ) == Board_MachiBBS ) {
             // TODO: need to refactoring.
-            parse_machiBBS();
+            m_threadData = Kita::parse_machibbs_dat( m_threadData );
             KURL url = m_datURL;
             make_cacheDir( url );
             writeCacheData();
@@ -155,78 +155,6 @@ void Access::slotThreadResult( KIO::Job* job )
     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;
-}
-
-
 void Access::slotReceiveThreadData( KIO::Job*, const QByteArray& data )
 {
     QString cstr( data );
index 0439986..c2e1fae 100644 (file)
@@ -55,9 +55,6 @@ namespace Kita
         bool m_firstReceive;
         bool m_invalidDataReceived;
 
-    private:
-        void parse_machiBBS();
-
     private slots:
         void slotReceiveThreadData( KIO::Job* job, const QByteArray& data );
         void slotThreadResult( KIO::Job* job );
index d64f804..19dbd33 100644 (file)
@@ -191,3 +191,74 @@ bool Kita::is2ch( const KURL& url )
 
     return false;
 }
+
+QString Kita::parse_machibbs_dat( const QString& datStr )
+{
+    QString ret;
+    QStringList lines = QStringList::split( "\n", datStr );
+    // 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;
+            }
+        }
+    }
+    return ret;
+}
\ No newline at end of file
index fa16c75..2473596 100644 (file)
@@ -39,6 +39,7 @@ namespace Kita
     uint datToSince( const QString& datURL );
     QString datToOfflaw( const QString& datURL );
     bool is2ch( const KURL& url );
+    QString parse_machibbs_dat( const QString& datStr );
 }
 
 #endif