/***************************************************************************
-* Copyright (C) 2003 by Hideki Ikemoto *
-* ikemo@wakaba.jp *
+* Copyright (C) 2003-2004 by Hideki Ikemoto *
+* ikemo@users.sourceforge.jp *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
QString cachePath = Kita::Cache::getPath( url );
QFile file( cachePath );
- if ( !file.open( IO_ReadOnly ) ) {
+ if ( !file.open( IO_ReadOnly ) )
+ {
return 0;
}
int dataSize = file.size();
// partial data¤¬Æþ¤Ã¤Æ¤ë¤Î¤Ç¤½¤ì¤ò½ñ¤´¹¤¨¤ë¡£
void Access::writeCacheData( const KURL& url )
{
- if ( m_orgData.isNull() && responseCode() == 304 ) {
+ if ( m_orgData.isNull() && responseCode() == 304 )
+ {
m_threadData = QString::null;
m_orgData = m_threadData;
return ;
- }
- if ( ! m_orgData.isNull() && responseCode() == 304 ) {
+ }
+ if ( ! m_orgData.isNull() && responseCode() == 304 )
+ {
m_threadData = m_orgData;
return ;
}
- if ( ! m_orgData.isNull() && responseCode() == 206 ) {
+ if ( ! m_orgData.isNull() && responseCode() == 206 )
+ {
m_threadData = m_orgData + m_threadData;
}
m_orgData = m_threadData;
- if ( m_invalidDataReceived ) {
+ if ( m_invalidDataReceived )
+ {
return;
}
-
+
QString cachePath = Kita::Cache::getPath( url );
FILE *fs = fopen( QFile::encodeName( cachePath ), "w" );
if ( !fs ) return ;
QString Access::getupdate()
{
QString getURL = m_url.url();
- if ( Kita::boardType( getURL ) == Board_MachiBBS ) {
+ if ( Kita::boardType( getURL ) == Board_MachiBBS )
+ {
getURL = Kita::datToThread( getURL );
}
m_firstReceive = FALSE;
m_invalidDataReceived = FALSE;
- if ( KURL( getURL ).protocol() != "k2ch" ) {
+ if ( KURL( getURL ).protocol() != "k2ch" )
+ {
KIO::SlaveConfig::self() ->setConfigData( "http",
KURL( getURL ).host(),
"UserAgent",
// use 'HTTP-Headers' metadata.
job->addMetaData( "PropagateHttpHeader", "true" );
- if ( ! m_orgData.isNull() ) {
- m_firstReceive = TRUE; /* remove first char. see also slotReceiveThreadData() */
+ 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" );
}
KURL cacheDir = KURL( cachePath, "." );
KURL cacheDir2 = KURL( cacheDir, ".." );
KURL cacheDir3 = KURL( cacheDir2, ".." );
- if ( !KIO::NetAccess::exists( cacheDir3 ) ) {
+ if ( !KIO::NetAccess::exists( cacheDir3 ) )
+ {
KIO::NetAccess::mkdir( cacheDir3 );
}
- if ( !KIO::NetAccess::exists( cacheDir2 ) ) {
+ if ( !KIO::NetAccess::exists( cacheDir2 ) )
+ {
KIO::NetAccess::mkdir( cacheDir2 );
}
- if ( !KIO::NetAccess::exists( cacheDir ) ) {
+ if ( !KIO::NetAccess::exists( cacheDir ) )
+ {
KIO::NetAccess::mkdir( cacheDir );
}
}
void Access::slotThreadResult( KIO::Job* job )
{
m_currentJob = 0;
- if ( job->error() ) {
+ if ( job->error() )
+ {
job->showErrorDialog();
- } else {
+ }
+ else
+ {
m_header = job->queryMetaData( "HTTP-Headers" );
}
-
- if ( m_threadData.length() ) {
- if ( Kita::boardType( m_url.url() ) == Board_MachiBBS ) {
+
+ if ( m_threadData.length() )
+ {
+ if ( Kita::boardType( m_url.url() ) == Board_MachiBBS )
+ {
// TODO: need to refactoring.
parse_machiBBS();
KURL url = m_url;
writeCacheData( url );
emit receiveData( m_threadData );
- } else {
+ }
+ else
+ {
KURL url = m_url;
make_cacheDir( url );
writeCacheData( url );
}
}
-
- if ( Kita::boardType( m_url.url() ) == Board_MachiBBS ) {
- }
+
+ if ( Kita::boardType( m_url.url() ) == Board_MachiBBS )
+ {}
emit finishLoad();
}
// 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 ) {
+ for ( QStringList::iterator it = lines.begin(); it != lines.end(); ++it )
+ {
QString line = (*it);
- if ( regexp.search( line ) != -1 ) {
+ if ( regexp.search( line ) != -1 )
+ {
int num = regexp.cap( 1 ).toInt();
QString name = regexp.cap( 2 );
QString date = regexp.cap( 3 );
QString id = regexp.cap( 5 );
QString message = regexp.cap( 6 );
QString datStr = name + "<><>" + date + " " + time + " ID:" + id
- + "<>" + message + "<>\n";
+ + "<>" + message + "<>\n";
ret += datStr;
- } else if ( regexp2.search( line ) != -1 ) {
+ }
+ else if ( regexp2.search( line ) != -1 )
+ {
int num = regexp2.cap( 1 ).toInt();
QString mail = regexp2.cap( 2 );
QString name = regexp2.cap( 3 );
QString id = regexp2.cap( 6 );
QString message = regexp2.cap( 7 );
QString datStr = name + "<>" + mail + "<>" + date + " " + time + " ID:" + id
- + "<>" + message + "<>\n";
+ + "<>" + message + "<>\n";
ret += datStr;
- } else if ( regexp3.search( line ) != -1 ) {
+ }
+ else if ( regexp3.search( line ) != -1 )
+ {
++it;
if ( it == lines.end() ) break;
QString nextLine = (*it);
- if ( regexp4.search( nextLine ) != -1 ) {
+ if ( regexp4.search( nextLine ) != -1 )
+ {
int num = regexp3.cap( 1 ).toInt();
QString name = regexp3.cap( 2 );
QString date = regexp3.cap( 3 );
QString id = regexp3.cap( 5 );
QString message = regexp4.cap( 1 );
QString datStr = name + "<><>" + date + " " + time + " ID:" + id
- + "<>" + message + "<>\n";
+ + "<>" + message + "<>\n";
ret += datStr;
}
- } else if ( regexp5.search( line ) != -1 ) {
+ }
+ else if ( regexp5.search( line ) != -1 )
+ {
++it;
if ( it == lines.end() ) break;
QString nextLine = (*it);
- if ( regexp4.search( nextLine ) != -1 ) {
+ if ( regexp4.search( nextLine ) != -1 )
+ {
int num = regexp5.cap( 1 ).toInt();
QString mail = regexp5.cap( 2 );
QString name = regexp5.cap( 3 );
QString id = regexp5.cap( 6 );
QString message = regexp4.cap( 1 );
QString datStr = name + "<>" + mail + "<>" + date + " " + time + " ID:" + id
- + "<>" + message + "<>\n";
+ + "<>" + message + "<>\n";
ret += datStr;
}
}
{
QString cstr( data );
/* If this is the first call at resumption, remove LF at head. */
- if(m_firstReceive) {
- if ( cstr[0] != '\n' ) {
+ if(m_firstReceive)
+ {
+ if ( cstr[0] != '\n' )
+ {
m_invalidDataReceived = TRUE;
}
- cstr = cstr.mid(1);
+ cstr = cstr.mid(1);
}
m_firstReceive = FALSE;
m_threadData += cstr ;
- if ( Kita::boardType( m_url.url() ) != Board_MachiBBS ) {
+ if ( Kita::boardType( m_url.url() ) != Board_MachiBBS )
+ {
emit receiveData( cstr );
}
}
QStringList headerList = QStringList::split( "\n", m_header );
QRegExp regexp( "Date: (...), (..) (...) (....) (..:..:..) .*" );
QString dateStr = headerList.grep( regexp ) [ 0 ];
- if ( regexp.search( dateStr ) == -1 ) {
+ if ( regexp.search( dateStr ) == -1 )
+ {
// invalid date format
return QDateTime::currentDateTime().toTime_t();
- } else {
+ }
+ else
+ {
// I hate this format ;p
QString usLocalDateStr = regexp.cap( 1 ) + " " + regexp.cap( 3 ) + " " +
regexp.cap( 2 ) + " " + regexp.cap( 5 ) + " " +
QStringList headerList = QStringList::split( "\n", m_header );
QRegExp regexp( "HTTP/1\\.[01] ([0-9]+) .*" );
QString dateStr = headerList.grep( regexp ) [ 0 ];
- if ( regexp.search( dateStr ) == -1 ) {
+ if ( regexp.search( dateStr ) == -1 )
+ {
// invalid response
return 0;
- } else {
+ }
+ else
+ {
return regexp.cap( 1 ).toInt();
}
}
"Kita",
"Do you want to delete Log ?",
QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
- == QMessageBox::Ok ) {
+ == QMessageBox::Ok )
+ {
KURL url = thread->datURL();
QString str = Kita::Cache::getPath( url );