{
QString refstr;
m_datURL = Kita::ParseMisc::parseURL( url, refstr);
- m_thread = Kita::Thread::getByURLNew( m_datURL );
+ m_thread = Kita::Thread::getByURLNew( m_datURL );
/* japanese strings */
m_spacestr = ". ";
m_framestr1 = ParseMisc::utf8ToUnicode( KITAUTF8_FRAME1 ); /* | */
m_framestr2 = ParseMisc::utf8ToUnicode( KITAUTF8_FRAME2 ); /* |- */
m_framestr3 = ParseMisc::utf8ToUnicode( KITAUTF8_FRAME3 ); /* L */
-
+
initPrivate();
}
-DatInfo::~DatInfo(){
+DatInfo::~DatInfo()
+{
deleteAccessJob();
}
}
/* private */
-void DatInfo::initPrivate(){
+void DatInfo::initPrivate()
+{
/* stop & delete dat loader */
deleteAccessJob();
m_nowLoading = FALSE;
m_lastLine = QString::null;
m_kokoyonNum = KitaThreadInfo::readNum( m_datURL.prettyURL() );
-
+
/* clear & resize ResDatVec */
RESDAT resdat;
resetResDat(resdat);
/* reset Abone */
resetAbonePrivate();
-
+
/* create dat loader */
m_access = new Kita::Access( m_datURL );
-
+
connect( m_access, SIGNAL( receiveData( const QString& ) ),
- SLOT( slotReceiveData( const QString& ) ) );
+ SLOT( slotReceiveData( const QString& ) ) );
connect( m_access, SIGNAL( finishLoad() ),SLOT( slotFinishLoad() ) );
/* get dat from cahce & copy it to buffer */
/* private */
-void DatInfo::resetResDat(RESDAT& resdat){
+void DatInfo::resetResDat(RESDAT& resdat)
+{
resdat.set = FALSE;
resdat.parsed = FALSE;
/* delete dat loader */ /* private */
void DatInfo::deleteAccessJob()
{
- if ( m_access ) {
+ if ( m_access )
+ {
m_access->killJob();
delete m_access;
m_access = NULL;
{
QStringList linelist;
int basenum = m_maxNum + 1;
-
+
// hack for machiBBS
- if ( Kita::boardType( m_datURL.url() ) == Board_MachiBBS && m_lastLine == QString::null && m_access->responseCode() == 200 ) {
+ if ( Kita::boardType( m_datURL.url() ) == Board_MachiBBS && m_lastLine == QString::null && m_access->responseCode() == 200 )
+ {
basenum = 1;
m_maxNum = 0;
}
-
+
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 );
-
- /* backup the last line */
- QStringList::iterator lastit = linelist.end();
- lastit--;
- 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;
+ 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 );
+
+ /* backup the last line */
+ QStringList::iterator lastit = linelist.end();
+ lastit--;
+ 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 */
+ else
+ { /* If rawData == null, then copy the last line */
- if ( m_lastLine != QString::null
- && m_lastLine.contains( "<>" ) == 4
- && m_lastLine.at(m_lastLine.length()-1) == '\n' ) {
+ if ( m_lastLine != QString::null
+ && m_lastLine.contains( "<>" ) == 4
+ && m_lastLine.at(m_lastLine.length()-1) == '\n' )
+ {
+
+ m_lastLine.truncate(m_lastLine.length()-1);/* remove LF */
+ linelist += m_lastLine;
+ m_lastLine = QString::null;
+ }
+ }
- 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();
- it != linelist.end(); ++it, ++basenum ) {
- if((*it) != QString::null){
- QString line = ParseMisc::qcpToUnicode((*it));
- setDat(line,basenum);
- }
+ it != linelist.end(); ++it, ++basenum )
+ {
+ if((*it) != QString::null)
+ {
+ QString line = ParseMisc::qcpToUnicode((*it));
+ setDat(line,basenum);
+ }
}
/* update thread info */
/* private */
-bool DatInfo::setDat( const QString& line, int num ){
+bool DatInfo::setDat( const QString& line, int num )
+{
if ( num <= 0 || (int) m_resDatVec.size() <= num ) return FALSE;
if ( line == QString::null ) return FALSE;
/* reset and set new data */
RESDAT& resdat = m_resDatVec[ num ];
resetResDat(resdat);
-
+
resdat.set = TRUE;
resdat.linestr = line;
if(m_maxNum < num) m_maxNum = num;
if(num == 1) parseDat ( num ); /* to get subject */
/* is this dat file broken ? */
- if ( line.contains( "<>" ) != 4 ) {
- resdat.broken = TRUE;
- m_broken = TRUE;
- }
-
+ if ( line.contains( "<>" ) != 4 )
+ {
+ resdat.broken = TRUE;
+ m_broken = TRUE;
+ }
+
return TRUE;
}
const KURL& DatInfo::url()
{
QMutexLocker locker( &m_mutex );
-
+
return m_datURL;
}
m_lock++; /* By locking, DatManager can't delete this while loading. */
connect( this, SIGNAL( receiveData() ),
- parent,SLOT( slotReceiveData() ) );
-
+ parent,SLOT( slotReceiveData() ) );
+
connect( this, SIGNAL( finishLoad() ),
- parent,SLOT( slotFinishLoad() ) );
+ parent,SLOT( slotFinishLoad() ) );
m_access->getupdate();
-
+
return TRUE;
}
/* slot called when Kita::Access
received new data */ /* private slot */
-void DatInfo::slotReceiveData(const QString& newLine){
+void DatInfo::slotReceiveData(const QString& newLine)
+{
int rescode = m_access->responseCode();
/* slot called when Kita::Access
finished loading new dat */ /* private slot */
-void DatInfo::slotFinishLoad(){
+void DatInfo::slotFinishLoad()
+{
/* copy the last line */
- copyRawDataToBuffer(QString::null);
-
+ copyRawDataToBuffer(QString::null);
+
/* finish loading session & emit signal to the parent object */
m_nowLoading = FALSE;
emit finishLoad();
/* disconnect signals */
disconnect( SIGNAL( receiveData() ));
disconnect( SIGNAL( finishLoad() ) );
-
+
if(m_lock) m_lock--;
}
{
QMutexLocker locker( &m_mutex );
if ( m_access == NULL ) return 0;
-
+
return m_access->responseCode();
}
{
QMutexLocker locker( &m_mutex );
if ( m_access == NULL ) return 0;
-
+
return m_access->serverTime();
}
/* public */
-bool DatInfo::deleteCache(QWidget* parent){
+bool DatInfo::deleteCache(QWidget* parent)
+{
- QMutexLocker locker( &m_mutex );
- if ( m_access == NULL ) return FALSE;
- if ( m_nowLoading ) return FALSE;
+ QMutexLocker locker( &m_mutex );
+ if ( m_access == NULL ) return FALSE;
+ if ( m_nowLoading ) return FALSE;
- bool ret = FALSE;
- if( m_thread ) ret = Kita::Access::deleteLog( m_thread, parent );
- KitaThreadInfo::removeThreadInfo( m_datURL.prettyURL() );
- if(ret) initPrivate();
+ bool ret = FALSE;
+ if( m_thread ) ret = Kita::Access::deleteLog( m_thread, parent );
+ KitaThreadInfo::removeThreadInfo( m_datURL.prettyURL() );
+ if(ret) initPrivate();
- return ret;
+ return ret;
}
/* public */
-bool DatInfo::isLoadingNow(){
+bool DatInfo::isLoadingNow()
+{
- QMutexLocker locker( &m_mutex );
+ QMutexLocker locker( &m_mutex );
- return m_nowLoading;
+ return m_nowLoading;
}
/* public */
-void DatInfo::stopLoading(){
+void DatInfo::stopLoading()
+{
/* Don't lock the mutex here !!!
It will cause deadlock , because
if ( num <= 0 || KITA_MAXRES <= num ) return QString::null;
if ( ! m_resDatVec[ num ].set ) return QString::null;
-
+
return m_resDatVec[ num ].linestr;
}
QString bodytext;
QString line = m_resDatVec[ num ].body;
-
+
ParseMisc::parseBODYdatText(PARSEMODE_TEXT,line,bodytext);
-
+
return bodytext;
}
bool showAddr = KitaConfig::showMailAddress();
QString titletext;
- ParseMisc::parseTITLEdatText(PARSEMODE_TEXT,num,showAddr,m_resDatVec[ num ],titletext);
+ ParseMisc::parseTITLEdatText(PARSEMODE_TEXT,num,showAddr,m_resDatVec[ num ],titletext);
return titletext;
}
QString retstr = QString::null;
bool showAddr = KitaConfig::showMailAddress();
-
- for(int num = startnum; num <= endnum; num++){
- if(!parseDat(num)) continue;
- if(checkAbonePrivate(num)) retstr += aboneHTML( num );
- else if(m_resDatVec[ num ].broken) retstr += brokenHTML( num );
- else retstr += ParseMisc::ResDatToHtml(m_resDatVec[ num ], num, showAddr );
+ for(int num = startnum; num <= endnum; num++)
+ {
+
+ if(!parseDat(num)) continue;
+ if(checkAbonePrivate(num)) retstr += aboneHTML( num );
+ else if(m_resDatVec[ num ].broken) retstr += brokenHTML( num );
+ else retstr += ParseMisc::ResDatToHtml(m_resDatVec[ num ], num, showAddr );
}
return retstr;
QString retstr = QString::null;
bool showAddr = KitaConfig::showMailAddress();
-
+
count = 0;
- for ( int i = 1; i <= m_maxNum; i++ ){
+ for ( int i = 1; i <= m_maxNum; i++ )
+ {
- if(!parseDat(i)) continue;
+ if(!parseDat(i)) continue;
- if(m_resDatVec[i].id == strid){
- count ++;
- if(checkAbonePrivate(i)) retstr += aboneHTML(i);
- else if(m_resDatVec[ i ].broken) retstr += brokenHTML(i);
- else retstr += ParseMisc::ResDatToHtml(m_resDatVec[i], i, showAddr);
- }
+ if(m_resDatVec[i].id == strid)
+ {
+ count ++;
+ if(checkAbonePrivate(i)) retstr += aboneHTML(i);
+ else if(m_resDatVec[ i ].broken) retstr += brokenHTML(i);
+ else retstr += ParseMisc::ResDatToHtml(m_resDatVec[i], i, showAddr);
+ }
}
return retstr;
/* private */
-QString DatInfo::aboneHTML(int num){
+QString DatInfo::aboneHTML(int num)
+{
QString tmpstr = QString( "<dl><dt>" );
tmpstr += QString().setNum( num ) + " " + ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
/* private */
-QString DatInfo::brokenHTML(int num){
+QString DatInfo::brokenHTML(int num)
+{
QString tmpstr = QString( "<dl><dt>" );
tmpstr += QString().setNum( num ) + " " + ParseMisc::utf8ToUnicode( KITAUTF8_NAME );
/*-------------------------------*/
/* Get HTML document of res tree.*/
/* For example, when rootnum = 1,
-
+
>>1
|-->>4
| |--->>10
/*---------------------------------------*/
/* Get HTML document of reverse res tree.*/
/* For example, when rootnum = 10,
-
+
>>10
|-->>5
| |--->>2
QString DatInfo::getTreeByResPrivate(
const int rootnum,
bool reverse, /* reverse search */
- int& count){
+ int& count)
+{
QString tmp = QString().setNum( rootnum );
QString retstr = "<a href=\"#" + tmp + "\">>>" + tmp + "</a><br>";
retstr += getTreeByResCore(rootnum,reverse,count,"");
-
- return retstr;
+
+ return retstr;
}
/* private */
{
if(!parseDat(rootnum)) return QString::null;
if( checkAbonePrivate(rootnum) ) return QString::null;
-
- QString retstr = QString::null ;
+
+ QString retstr = QString::null ;
count = 0;
QStringList strlists;
- if( !reverse ){
-
- /* collect responses that have anchor to rootnum */
- for ( int i = rootnum+1; i <= m_maxNum; i++ ){
- if(checkAbonePrivate( i ) ) continue;
- if(checkRes(i,rootnum)){
- count ++;
- strlists += QString().setNum( i );
- }
- }
-
+ if( !reverse )
+ {
+
+ /* collect responses that have anchor to rootnum */
+ for ( int i = rootnum+1; i <= m_maxNum; i++ )
+ {
+ if(checkAbonePrivate( i ) ) continue;
+ if(checkRes(i,rootnum))
+ {
+ count ++;
+ strlists += QString().setNum( i );
+ }
+ }
+
}
- else { /* collect responses for which rootnum has anchors */
-
- setAncList(rootnum);
- AncList& anclist = m_resDatVec[ rootnum ].anclist;
- for ( AncList::iterator it = anclist.begin(); it != anclist.end(); ++it ){
- for( int i = (*it).from; i <= QMIN(rootnum-1,(*it).to) ; i++){
- if(checkAbonePrivate(i) ) continue;
- count ++;
- strlists += QString().setNum( i );
- }
- }
+ else
+ { /* collect responses for which rootnum has anchors */
+
+ setAncList(rootnum);
+ AncList& anclist = m_resDatVec[ rootnum ].anclist;
+ for ( AncList::iterator it = anclist.begin(); it != anclist.end(); ++it )
+ {
+ for( int i = (*it).from; i <= QMIN(rootnum-1,(*it).to) ; i++)
+ {
+ if(checkAbonePrivate(i) ) continue;
+ count ++;
+ strlists += QString().setNum( i );
+ }
+ }
}
/* make HTML document */
- if(count){
-
- for ( QStringList::iterator it = strlists.begin(); it != strlists.end(); ++it ){
- QString tmpstr;
- if((*it) == strlists.last()) tmpstr = m_framestr3; /* 'L' */
- else tmpstr = m_framestr2; /* '|-' */
-
- retstr += prestr + tmpstr + "<a href=\"#" + (*it) + "\">>>" + (*it) + "</a><br>";
-
- /* call myself recursively */
- int tmpnum;
- tmpstr = prestr;
- if((*it) == strlists.last()) tmpstr += m_spacestr + m_spacestr + m_spacestr; /* " " */
- else tmpstr += m_framestr1 + m_spacestr; /* "| " */
- retstr += getTreeByResCore((*it).toInt(),reverse,tmpnum,tmpstr);
- count += tmpnum;
- }
+ if(count)
+ {
+
+ for ( QStringList::iterator it = strlists.begin(); it != strlists.end(); ++it )
+ {
+ QString tmpstr;
+ if((*it) == strlists.last()) tmpstr = m_framestr3; /* 'L' */
+ else tmpstr = m_framestr2; /* '|-' */
+
+ retstr += prestr + tmpstr + "<a href=\"#" + (*it) + "\">>>" + (*it) + "</a><br>";
+
+ /* call myself recursively */
+ int tmpnum;
+ tmpstr = prestr;
+ if((*it) == strlists.last()) tmpstr += m_spacestr + m_spacestr + m_spacestr; /* " " */
+ else tmpstr += m_framestr1 + m_spacestr; /* "| " */
+ retstr += getTreeByResCore((*it).toInt(),reverse,tmpnum,tmpstr);
+ count += tmpnum;
+ }
}
return retstr;
setAncList(num);
AncList& anclist = m_resDatVec[ num ].anclist;
- for ( AncList::iterator it = anclist.begin(); it != anclist.end(); ++it ){
- if ( target >= (*it).from && target <= (*it).to ) return TRUE;
+ for ( AncList::iterator it = anclist.begin(); it != anclist.end(); ++it )
+ {
+ if ( target >= (*it).from && target <= (*it).to ) return TRUE;
}
return FALSE;
anclist[1].from = 4,
anclist[1].to = 4.
*/
-void DatInfo::setAncList(int num){
+void DatInfo::setAncList(int num)
+{
if(! parseDat(num)) return;
if( m_resDatVec[ num ].setAnclist ) return;
m_resDatVec[ num ].setAnclist = TRUE;
-
+
QString linkstr;
int refNum[2];
unsigned int pos;
AncList& anclist = m_resDatVec[ num ].anclist;
anclist.clear();
-
+
QString line = m_resDatVec[ num ].body;
/* remove HTML tags */
unsigned int length = line.length();
/* parse body */
- for ( i = 0 ; i < length ; i++ ) {
-
- if( chpt[ i ].unicode() == UTF16_BRACKET || /* > */
- (chpt[ i] == '&' && chpt[ i+1] == 'g' && chpt[ i+2] == 't' && chpt[ i+3] == ';') /* ">" */
- ){
- while(ParseMisc::parseResAnchor(chpt+i,length-i,linkstr,refNum,pos)){
- if(refNum[1] < refNum[0]) refNum[1] = refNum[0];
- anctmp.from = refNum[0];
- anctmp.to = refNum[1];
- anclist += anctmp;
- i += pos;
- }
-
- i += (pos-1);
- }
+ for ( i = 0 ; i < length ; i++ )
+ {
+
+ if( chpt[ i ].unicode() == UTF16_BRACKET || /* > */
+ (chpt[ i] == '&' && chpt[ i+1] == 'g' && chpt[ i+2] == 't' && chpt[ i+3] == ';') /* ">" */
+ )
+ {
+ while(ParseMisc::parseResAnchor(chpt+i,length-i,linkstr,refNum,pos))
+ {
+ if(refNum[1] < refNum[0]) refNum[1] = refNum[0];
+ anctmp.from = refNum[0];
+ anctmp.to = refNum[1];
+ anclist += anctmp;
+ i += pos;
+ }
+
+ i += (pos-1);
+ }
}
/* parse name */
chpt = line.unicode();
i = 0;
length = line.length();
-
- while(ParseMisc::parseResAnchor(chpt+i,length-i,linkstr,refNum,pos)){
- if(refNum[1] < refNum[0]) refNum[1] = refNum[0];
- anctmp.from = refNum[0];
- anctmp.to = refNum[1];
- anclist += anctmp;
- i += pos;
- }
+
+ while(ParseMisc::parseResAnchor(chpt+i,length-i,linkstr,refNum,pos))
+ {
+ if(refNum[1] < refNum[0]) refNum[1] = refNum[0];
+ anctmp.from = refNum[0];
+ anctmp.to = refNum[1];
+ anclist += anctmp;
+ i += pos;
+ }
}
/* This function returns the element
of DOM.
-
+
This function checks Abone
internally. So, if the res is
aboned,the output is "abone" node.
/* output */
DOM::Element& retelm)
{
-
+
QMutexLocker locker( &m_mutex );
if(!parseDat(num)) return FALSE;
bool abone = checkAbonePrivate( num );
RESDAT& resdat = m_resDatVec[ num ];
-
- if ( !resdat.broken && !abone ){
-
- /* title node */
- titlenode = hdoc.createElement( "DT" );
- ParseMisc::parseTITLEdat(PARSEMODE_DOM,hdoc,num,showAddr,resdat,titlenode,tmpstr);
-
- /* body node */
- bodynode = hdoc.createElement( "DD" );
- {
- /* put the span node at the head of each line */
- if ( showAA ){
-
- tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
- {
- tmpelm.setAttribute( "style", "color: white" );
- tmpelm.appendChild( hdoc.createTextNode( "" ) );
- }
- }
-
- ParseMisc::parseBODYdat(PARSEMODE_DOM,resdat.body,hdoc,showAA,bodynode,tmpstr);
- }
-
- } else { /* abone or data is broken */
-
- QString namestr;
- QString bodystr;
-
- if(abone){ /* "abone" node */
- namestr = ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
- bodystr = ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
- status = "abone";
- }
- else{ /* "broken" node */
- namestr = ParseMisc::utf8ToUnicode( KITAUTF8_NAME );
- bodystr = ParseMisc::utf8ToUnicode( KITAUTF8_KOWARE );
- status = "broken";
- }
-
- /* title node */
- titlenode = hdoc.createElement( "DT" );
- titlenode.appendChild( hdoc.createTextNode(
+
+ if ( !resdat.broken && !abone )
+ {
+
+ /* title node */
+ titlenode = hdoc.createElement( "DT" );
+ ParseMisc::parseTITLEdat(PARSEMODE_DOM,hdoc,num,showAddr,resdat,titlenode,tmpstr);
+
+ /* body node */
+ bodynode = hdoc.createElement( "DD" );
+ {
+ /* put the span node at the head of each line */
+ if ( showAA )
+ {
+
+ tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
+ {
+ tmpelm.setAttribute( "style", "color: white" );
+ tmpelm.appendChild( hdoc.createTextNode( "" ) );
+ }
+ }
+
+ ParseMisc::parseBODYdat(PARSEMODE_DOM,resdat.body,hdoc,showAA,bodynode,tmpstr);
+ }
+
+ }
+ else
+ { /* abone or data is broken */
+
+ QString namestr;
+ QString bodystr;
+
+ if(abone)
+ { /* "abone" node */
+ namestr = ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
+ bodystr = ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
+ status = "abone";
+ }
+ else
+ { /* "broken" node */
+ namestr = ParseMisc::utf8ToUnicode( KITAUTF8_NAME );
+ bodystr = ParseMisc::utf8ToUnicode( KITAUTF8_KOWARE );
+ status = "broken";
+ }
+
+ /* title node */
+ titlenode = hdoc.createElement( "DT" );
+ titlenode.appendChild( hdoc.createTextNode(
QString().setNum( num ) + " " + namestr ) );
- /* body node */
- bodynode = hdoc.createElement( "DD" );
- tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
- {
- tmpelm.setAttribute( "style", "color: red" );
- tmpelm.appendChild( hdoc.createTextNode( bodystr ) );
- }
+ /* body node */
+ bodynode = hdoc.createElement( "DD" );
+ tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
+ {
+ tmpelm.setAttribute( "style", "color: red" );
+ tmpelm.appendChild( hdoc.createTextNode( bodystr ) );
+ }
}
bodynode.appendChild( hdoc.createElement( "BR" ) );
bodynode.appendChild( hdoc.createElement( "BR" ) );
-
+
/*-----------------------------*/
retelm = hdoc.createElement( "DIV" );
{
retelm.setAttribute( "kita_type", "res" );
- retelm.setAttribute( "kita_status", status );
+ retelm.setAttribute( "kita_status", status );
retelm.setAttribute( "id", QString().setNum( num ) );
retelm.setAttribute( "kita_rname", resdat.name );
retelm.setAttribute( "kita_rid", resdat.id );
int count = 0;
- for ( int i = 1; i <= m_maxNum; i++ ) {
+ for ( int i = 1; i <= m_maxNum; i++ )
+ {
- if( !parseDat(i) ) continue;
- if( checkAbonePrivate( i ) ) continue;
+ if( !parseDat(i) ) continue;
+ if( checkAbonePrivate( i ) ) continue;
- if ( m_resDatVec[i].id == strid ) count++;
+ if ( m_resDatVec[i].id == strid ) count++;
}
- return count;
+ return count;
}
/* public */
int DatInfo::getKokoyonNum()
{
QMutexLocker locker( &m_mutex );
-
+
return QMIN(m_kokoyonNum, m_maxNum);
}
num = QMIN(num, m_maxNum);
m_kokoyonNum = num;
- KitaThreadInfo::setReadNum( m_datURL.prettyURL(), num );
+ KitaThreadInfo::setReadNum( m_datURL.prettyURL(), num );
}
/* public */
int DatInfo::getDatSize()
{
QMutexLocker locker( &m_mutex );
-
+
return m_rawData.length();
}
{
QMutexLocker locker( &m_mutex );
if(!parseDat(num)) return FALSE;
-
+
return m_resDatVec[ num ].broken;
}
{
QMutexLocker locker( &m_mutex );
if(!parseDat(num)) return FALSE;
-
+
if(m_resDatVec[num].id == strid) return TRUE;
return FALSE;
/* Are keywords included ? */ /* public */
bool DatInfo::checkWord(QStringList& stlist, /* list of keywords */
- int num,
- bool checkOR /* AND or OR search */
- )
+ int num,
+ bool checkOR /* AND or OR search */
+ )
{
QMutexLocker locker( &m_mutex );
if(!parseDat(num)) return FALSE;
QString str_text = m_resDatVec[ num ].body;
-
- for ( QStringList::iterator it = stlist.begin(); it != stlist.end(); ++it ) {
- QRegExp regexp( (*it) );
- regexp.setCaseSensitive( FALSE );
+ for ( QStringList::iterator it = stlist.begin(); it != stlist.end(); ++it )
+ {
+
+ QRegExp regexp( (*it) );
+ regexp.setCaseSensitive( FALSE );
- if ( checkOR ) { /* OR */
- if ( str_text.find( regexp, 0 ) != -1 ) {
+ if ( checkOR )
+ { /* OR */
+ if ( str_text.find( regexp, 0 ) != -1 )
+ {
return TRUE;
}
- } else { /* AND */
+ }
+ else
+ { /* AND */
if ( str_text.find( regexp, 0 ) == -1 ) return FALSE;
}
}
m_resDatVec[ num ].checkAbone = TRUE;
bool checktmp = FALSE;
-
+
if( m_aboneByID )
- checktmp = checkAboneCore(m_resDatVec[ num ].id,KitaConfig::aboneIDList());
+ checktmp = checkAboneCore(m_resDatVec[ num ].id,KitaConfig::aboneIDList());
if(!checktmp && m_aboneByName )
- checktmp = checkAboneCore(m_resDatVec[ num ].parsedName,KitaConfig::aboneNameList());
+ checktmp = checkAboneCore(m_resDatVec[ num ].parsedName,KitaConfig::aboneNameList());
if(!checktmp && m_aboneByBody )
- checktmp = checkAboneCore(m_resDatVec[ num ].body,KitaConfig::aboneWordList());
+ checktmp = checkAboneCore(m_resDatVec[ num ].body,KitaConfig::aboneWordList());
if(!checktmp && m_aboneByRes )
{
- setAncList(num);
- AncList& anclist = m_resDatVec[ num ].anclist;
-
- for ( AncList::iterator it = anclist.begin();
- it != anclist.end() && !checktmp ; ++it ){
-
- int refNum = (*it).from;
- int refNum2 = (*it).to;
-
- /* I don't want to enter loop... */
- if ( refNum >= num ) continue;
- if ( refNum2 >= num ) refNum2 = num - 1;
-
- for (int i = refNum; i <= refNum2; i++ ){
- if (checkAbonePrivate(i)){
- checktmp = TRUE;
- break;
- }
- }
- }
+ setAncList(num);
+ AncList& anclist = m_resDatVec[ num ].anclist;
+
+ for ( AncList::iterator it = anclist.begin();
+ it != anclist.end() && !checktmp ; ++it )
+ {
+
+ int refNum = (*it).from;
+ int refNum2 = (*it).to;
+
+ /* I don't want to enter loop... */
+ if ( refNum >= num ) continue;
+ if ( refNum2 >= num ) refNum2 = num - 1;
+
+ for (int i = refNum; i <= refNum2; i++ )
+ {
+ if (checkAbonePrivate(i))
+ {
+ checktmp = TRUE;
+ break;
+ }
+ }
+ }
}
-
+
m_resDatVec[ num ].abone = checktmp;
return m_resDatVec[ num ].abone;
}
-/* private */
+/* private */
bool DatInfo::checkAboneCore(const QString& str, QStringList& strlist)
{
- if(strlist.count()){
-
- int i;
- for ( QStringList::iterator it = strlist.begin();
- it != strlist.end(); ++it ) {
- i = str.find( ( *it ) );
- if ( i != -1 ) {
- return TRUE;
- }
- }
+ if(strlist.count())
+ {
+
+ int i;
+ for ( QStringList::iterator it = strlist.begin();
+ it != strlist.end(); ++it )
+ {
+ i = str.find( ( *it ) );
+ if ( i != -1 )
+ {
+ return TRUE;
+ }
+ }
}
return FALSE;
ParseMisc::parseResDat. In short, this
splits the raw date into name, id,
date, and bodytext, etc.
-
+
Note that this function keeps data as
the raw data. So, you need to parse them
later by getPlainBody, getHtml,
getDomElement, etc.
*/ /* private */
-bool DatInfo::parseDat( int num ){
+bool DatInfo::parseDat( int num )
+{
if ( num <= 0 || KITA_MAXRES <= num ) return FALSE;
if( m_resDatVec[ num ].parsed ) return TRUE;
if( !ParseMisc::parseResDat( m_resDatVec[ num ], tmpstr ) ) return FALSE;
/* get subject */
- if ( m_subject == QString::null && tmpstr != QString::null ){
- m_subject = tmpstr;
- Kita::Thread::setName( m_datURL.prettyURL(), m_subject );
+ if ( m_subject == QString::null && tmpstr != QString::null )
+ {
+ m_subject = tmpstr;
+ Kita::Thread::setName( m_datURL.prettyURL(), m_subject );
}
return TRUE;
}
-
-
-
-/**************************************************************************
+/***************************************************************************
* Copyright (C) 2003 by Hideki Ikemoto , (c)2004 by 421 *
- * ikemo@wakaba.jp *
+ * 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 *
namespace DOM
{
-class HTMLDocument;
-class Element;
-}
+ class HTMLDocument;
+ class Element;
+}
enum{
/* ResDatVec is the Database for responses. */
/* For example, No.5 res has name = "foo", id "id1234", and anchors >>2-3 and >>4,
then,
-
+
m_resDatVec[5].name = "foo",
m_resDatVec[5].id = "id1234",
m_resDatVec[5].anclist[0].from = 2,
m_resDatVec[5].anclist[0].to = 3,
m_resDatVec[5].anclist[1].from = 4,
m_resDatVec[5].anclist[1].to = 4.
-
+
*/
-struct ANCNUM{
+struct ANCNUM
+{
int from;
int to;
};
typedef QValueList<ANCNUM> AncList;
-/* Data of one response */
-struct RESDAT{
+/* Data of one response */
+struct RESDAT
+{
+
+ bool set; /* Is linestr set ? */
- bool set; /* Is linestr set ? */
+ QString linestr; /* raw line strings */
- QString linestr; /* raw line strings */
+ /*-------*/
- /*-------*/
-
- bool parsed; /* Is dat parsed ? */
+ bool parsed; /* Is dat parsed ? */
- bool broken; /* This dat is broken */
+ bool broken; /* This dat is broken */
bool marked;
- QString name;
- QString parsedName;
- QString address;
- QString body;
- QString id;
- QDateTime dateTime;
- QString dateId;
+ QString name;
+ QString parsedName;
+ QString address;
+ QString body;
+ QString id;
+ QDateTime dateTime;
+ QString dateId;
+
+ /*-------*/
- /*-------*/
-
- bool setAnclist; /* Is anclist set ? */
+ bool setAnclist; /* Is anclist set ? */
- AncList anclist; /* anchor list. See also setAncList() */
+ AncList anclist; /* anchor list. See also setAncList() */
- /*-------*/
+ /*-------*/
- bool checkAbone; /* Is abone checked ? */
+ bool checkAbone; /* Is abone checked ? */
- bool abone;
+ bool abone;
};
typedef QValueVector<RESDAT> ResDatVec;
namespace Kita
{
-class Access;
-class Thread;
+ class Access;
+ class Thread;
-/*-----------------------*/
+ /*-----------------------*/
-class DatInfo : public QObject
+ class DatInfo : public QObject
{
- Q_OBJECT
-
- QMutex m_mutex;
-
- /* basic information */
- int m_maxNum;
- QString m_rawData;
- KURL m_datURL;
- QString m_subject;
- bool m_broken;
- ResDatVec m_resDatVec;
- int m_lock;
- int m_kokoyonNum; /* kokomade yonda */
-
- /* for caching */
- Access* m_access;
- Thread* m_thread;
- QString m_lastLine;
- bool m_nowLoading;
-
- /* abone */
- bool m_aboneByID;
- bool m_aboneByName;
- bool m_aboneByBody;
- bool m_aboneByRes;
-
-
- /* japanese strings */
- QString m_spacestr;
- QString m_framestr1; /* '|' */
- QString m_framestr2; /* '|-' */
- QString m_framestr3; /* 'L' */
-
- /*-------------------------------*/
-
- public:
-
- DatInfo();
- DatInfo( const KURL& url );
- ~DatInfo();
- void init();
- const KURL& url();
-
- /* for caching */
- bool updateCache(const QObject* parent);
- int getResponseCode();
- int getServerTime();
- bool deleteCache(QWidget* parent);
- bool isLoadingNow();
- void stopLoading();
-
- /* lock, unlock */
- void lock();
- void unlock();
- int isLocked();
-
- /* string data */
- const QString& getSubject();
- const QString& getRawDat();
- const QString& getDat( int num );
- const QString& getId( int num );
- const QString& getName( int num );
- const QString& getBody( int num );
- QString getPlainName(int num);
- QString getPlainBody(int num);
- QString getPlainTitle(int num);
-
- /* HTML data */
- QString getHtml(int startnum, int endnum);
- QString getHtmlByID(const QString& strid, int &count );
- QString getTreeByRes(const int rootnum, int& count );
- QString getTreeByResReverse(const int rootnum, int& count );
-
- /* DOM element */
- bool getDomElement(int num, DOM::HTMLDocument& hdoc, DOM::Element& retelm);
-
- /* numerical data */
- int getMaxResNumber();
- int getNumByID( const QString& strid );
- int getKokoyonNum();
- void setKokoyonNum(int num);
- int getDatSize();
-
- /* several informations */
- bool isResValid(int num);
- bool isBroken();
- bool isResBroken(int num);
- bool checkID(const QString& strid, int num );
- bool checkWord(QStringList& stlist, int num, bool checkOR);
- bool isMarked( int num );
- void setMark( int num, bool mark );
-
- /* abone check */
- bool checkAbone(int num);
- void resetAbone();
-
- /*-------------------------*/
-
- private:
-
- void initPrivate();
- void resetResDat(RESDAT& resdat);
- void deleteAccessJob();
-
- /* copy data */
- void copyRawDataToBuffer(const QString& rawData);
- bool setDat( const QString& line, int num );
-
- /* HTML data */
- QString aboneHTML(int num);
- QString brokenHTML(int num);
- QString getTreeByResPrivate(const int rootnum,bool reverse,int& count);
- QString getTreeByResCore(const int rootnum, bool reverse, int& count, QString prestr);
- bool checkRes(const int num, const int target );
- void setAncList(int num);
-
- /* for abone */
- void resetAbonePrivate();
- bool checkAbonePrivate(int num);
- bool checkAboneCore(const QString& str, QStringList& strlist);
-
- /* parsing funtions */
- bool parseDat( int num );
-
- /*----------------------------*/
-
- private slots:
-
- void slotReceiveData(const QString& newLine);
- void slotFinishLoad();
-
- signals:
+ Q_OBJECT
+
+ QMutex m_mutex;
+
+ /* basic information */
+ int m_maxNum;
+ QString m_rawData;
+ KURL m_datURL;
+ QString m_subject;
+ bool m_broken;
+ ResDatVec m_resDatVec;
+ int m_lock;
+ int m_kokoyonNum; /* kokomade yonda */
+
+ /* for caching */
+ Access* m_access;
+ Thread* m_thread;
+ QString m_lastLine;
+ bool m_nowLoading;
+
+ /* abone */
+ bool m_aboneByID;
+ bool m_aboneByName;
+ bool m_aboneByBody;
+ bool m_aboneByRes;
+
+
+ /* japanese strings */
+ QString m_spacestr;
+ QString m_framestr1; /* '|' */
+ QString m_framestr2; /* '|-' */
+ QString m_framestr3; /* 'L' */
+
+ /*-------------------------------*/
+
+ public:
+
+ DatInfo();
+ DatInfo( const KURL& url );
+ ~DatInfo();
+ void init();
+ const KURL& url();
+
+ /* for caching */
+ bool updateCache(const QObject* parent);
+ int getResponseCode();
+ int getServerTime();
+ bool deleteCache(QWidget* parent);
+ bool isLoadingNow();
+ void stopLoading();
+
+ /* lock, unlock */
+ void lock();
+ void unlock();
+ int isLocked();
+
+ /* string data */
+ const QString& getSubject();
+ const QString& getRawDat();
+ const QString& getDat( int num );
+ const QString& getId( int num );
+ const QString& getName( int num );
+ const QString& getBody( int num );
+ QString getPlainName(int num);
+ QString getPlainBody(int num);
+ QString getPlainTitle(int num);
+
+ /* HTML data */
+ QString getHtml(int startnum, int endnum);
+ QString getHtmlByID(const QString& strid, int &count );
+ QString getTreeByRes(const int rootnum, int& count );
+ QString getTreeByResReverse(const int rootnum, int& count );
+
+ /* DOM element */
+ bool getDomElement(int num, DOM::HTMLDocument& hdoc, DOM::Element& retelm);
+
+ /* numerical data */
+ int getMaxResNumber();
+ int getNumByID( const QString& strid );
+ int getKokoyonNum();
+ void setKokoyonNum(int num);
+ int getDatSize();
+
+ /* several informations */
+ bool isResValid(int num);
+ bool isBroken();
+ bool isResBroken(int num);
+ bool checkID(const QString& strid, int num );
+ bool checkWord(QStringList& stlist, int num, bool checkOR);
+ bool isMarked( int num );
+ void setMark( int num, bool mark );
+
+ /* abone check */
+ bool checkAbone(int num);
+ void resetAbone();
+
+ /*-------------------------*/
+
+ private:
+
+ void initPrivate();
+ void resetResDat(RESDAT& resdat);
+ void deleteAccessJob();
+
+ /* copy data */
+ void copyRawDataToBuffer(const QString& rawData);
+ bool setDat( const QString& line, int num );
+
+ /* HTML data */
+ QString aboneHTML(int num);
+ QString brokenHTML(int num);
+ QString getTreeByResPrivate(const int rootnum,bool reverse,int& count);
+ QString getTreeByResCore(const int rootnum, bool reverse, int& count, QString prestr);
+ bool checkRes(const int num, const int target );
+ void setAncList(int num);
+
+ /* for abone */
+ void resetAbonePrivate();
+ bool checkAbonePrivate(int num);
+ bool checkAboneCore(const QString& str, QStringList& strlist);
+
+ /* parsing funtions */
+ bool parseDat( int num );
+
+ /*----------------------------*/
+
+ private slots:
+
+ void slotReceiveData(const QString& newLine);
+ void slotFinishLoad();
+
+ signals:
void receiveData();
- void finishLoad();
+ void finishLoad();
};
}