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();
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 );
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 );
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
uint datToSince( const QString& datURL );
QString datToOfflaw( const QString& datURL );
bool is2ch( const KURL& url );
+ QString parse_machibbs_dat( const QString& datStr );
}
#endif