1 /**************************************************************************
2 * Copyright (C) 2003 by Hideki Ikemoto , (c)2004 by 421 *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
12 #include <qstringlist.h>
14 #include <dom/html_document.h>
15 #include <dom/html_element.h>
16 #include <dom/dom_text.h>
19 #include "datmanager.h"
20 #include "parsemisc.h"
23 #include "threadinfo.h"
24 #include "kitaconfig.h"
25 #include "kita-utf8.h"
26 #include "kita-utf16.h"
27 #include "kita_misc.h"
31 #define KITA_MAXRES 1200
34 /*------------------------------------------------------*/
35 /* DatInfo stores & handles all information about *.dat */
37 DatInfo::DatInfo( const KURL& url ) : m_access ( 0 )
40 m_datURL = Kita::ParseMisc::parseURL( url, refstr);
41 m_thread = Kita::Thread::getByURLNew( m_datURL );
43 /* japanese strings */
45 m_framestr1 = ParseMisc::utf8ToUnicode( KITAUTF8_FRAME1 ); /* | */
46 m_framestr2 = ParseMisc::utf8ToUnicode( KITAUTF8_FRAME2 ); /* |- */
47 m_framestr3 = ParseMisc::utf8ToUnicode( KITAUTF8_FRAME3 ); /* L */
58 /* Usually, don't call this. */ /* public */
61 QMutexLocker locker( &m_mutex );
67 void DatInfo::initPrivate(){
69 /* stop & delete dat loader */
74 m_rawData = QString::null;
75 m_subject = QString::null;
79 m_lastLine = QString::null;
80 m_kokoyonNum = KitaThreadInfo::readNum( m_datURL.prettyURL() );
82 /* clear & resize ResDatVec */
86 m_resDatVec.resize(KITA_MAXRES,resdat);
91 /* create dat loader */
92 m_access = new Kita::Access( m_datURL );
94 connect( m_access, SIGNAL( receiveData( const QString& ) ),
95 SLOT( slotReceiveData( const QString& ) ) );
96 connect( m_access, SIGNAL( finishLoad() ),SLOT( slotFinishLoad() ) );
98 /* get dat from cahce & copy it to buffer */
99 copyRawDataToBuffer(m_access->getcache());
100 copyRawDataToBuffer(QString::null); /* copy the last line */
105 void DatInfo::resetResDat(RESDAT& resdat){
108 resdat.parsed = FALSE;
109 resdat.broken = FALSE;
110 resdat.setAnclist = FALSE;
111 resdat.anclist.clear();
112 resdat.checkAbone = FALSE;
113 resdat.abone = FALSE;
114 resdat.marked = FALSE;
119 /* delete dat loader */ /* private */
120 void DatInfo::deleteAccessJob()
129 /* copy raw lines to buffer */
132 You need to call this function last
133 with rawData = QString::null in order
134 to copy the last line to buffer. */ /* private */
135 void DatInfo::copyRawDataToBuffer(const QString& rawData)
137 QStringList linelist;
138 int basenum = m_maxNum + 1;
141 if ( Kita::boardType( m_datURL.url() ) == Board_MachiBBS && m_lastLine == QString::null && m_access->responseCode() == 200 ) {
146 bool endIsLF = FALSE;
147 if ( rawData != QString::null ){
149 if(rawData.at(rawData.length()-1) == '\n') endIsLF = TRUE;
151 /* split the raw data */
152 m_lastLine += rawData;
153 linelist = QStringList::split( "\n", m_lastLine );
155 /* backup the last line */
156 QStringList::iterator lastit = linelist.end();
158 if( lastit != linelist.end() ){
159 m_lastLine = (*lastit);
160 linelist.remove(lastit);
162 /* If the last char of rawData is LF, then
163 add LF to m_lastLine, because LF was
164 removed by above QStringList::split(). */
165 if(endIsLF) m_lastLine += '\n';
167 else m_lastLine = QString::null;
170 else{ /* If rawData == null, then copy the last line */
172 if ( m_lastLine != QString::null
173 && m_lastLine.contains( "<>" ) == 4
174 && m_lastLine.at(m_lastLine.length()-1) == '\n' ) {
176 m_lastLine.truncate(m_lastLine.length()-1);/* remove LF */
177 linelist += m_lastLine;
178 m_lastLine = QString::null;
182 /* copy lines to buffer */
183 for ( QStringList::iterator it = linelist.begin();
184 it != linelist.end(); ++it, ++basenum ) {
185 if((*it) != QString::null){
186 QString line = ParseMisc::qcpToUnicode((*it));
187 setDat(line,basenum);
191 /* update thread info */
192 if( m_thread ) m_thread->setResNum( m_maxNum );
193 KitaThreadInfo::setReadNum( m_datURL.prettyURL(), m_maxNum );
199 bool DatInfo::setDat( const QString& line, int num ){
201 if ( num <= 0 || (int) m_resDatVec.size() <= num ) return FALSE;
202 if ( line == QString::null ) return FALSE;
204 /* reset and set new data */
205 RESDAT& resdat = m_resDatVec[ num ];
209 resdat.linestr = line;
210 if(m_maxNum < num) m_maxNum = num;
211 m_rawData += line + '\n';
213 if(num == 1) parseDat ( num ); /* to get subject */
215 /* is this dat file broken ? */
216 if ( line.contains( "<>" ) != 4 ) {
217 resdat.broken = TRUE;
227 const KURL& DatInfo::url()
229 QMutexLocker locker( &m_mutex );
236 /*--------------------------------------*/
237 /* cache handling functions */
241 /* When Kita::Access received new data,
242 slotReceiveData is called. */
244 /* When Kita::Access fineshed loading,
245 slotFinishLoad is called, and
246 DatInfo emits the finishLoad signal to the parent object */ /* public */
247 bool DatInfo::updateCache(const QObject* parent)
249 QMutexLocker locker( &m_mutex );
250 if ( m_access == NULL ) return FALSE;
251 if ( m_nowLoading ) return FALSE;
254 m_lock++; /* By locking, DatManager can't delete this while loading. */
256 connect( this, SIGNAL( receiveData() ),
257 parent,SLOT( slotReceiveData() ) );
259 connect( this, SIGNAL( finishLoad() ),
260 parent,SLOT( slotFinishLoad() ) );
262 m_access->getupdate();
268 /* slot called when Kita::Access
269 received new data */ /* private slot */
270 void DatInfo::slotReceiveData(const QString& newLine){
272 int rescode = m_access->responseCode();
274 if(rescode != 200 && rescode != 206) return;
276 copyRawDataToBuffer(newLine);
282 /* slot called when Kita::Access
283 finished loading new dat */ /* private slot */
284 void DatInfo::slotFinishLoad(){
286 /* copy the last line */
287 copyRawDataToBuffer(QString::null);
289 /* finish loading session & emit signal to the parent object */
290 m_nowLoading = FALSE;
293 /* disconnect signals */
294 disconnect( SIGNAL( receiveData() ));
295 disconnect( SIGNAL( finishLoad() ) );
302 int DatInfo::getResponseCode()
304 QMutexLocker locker( &m_mutex );
305 if ( m_access == NULL ) return 0;
307 return m_access->responseCode();
312 int DatInfo::getServerTime()
314 QMutexLocker locker( &m_mutex );
315 if ( m_access == NULL ) return 0;
317 return m_access->serverTime();
322 bool DatInfo::deleteCache(QWidget* parent){
324 QMutexLocker locker( &m_mutex );
325 if ( m_access == NULL ) return FALSE;
326 if ( m_nowLoading ) return FALSE;
329 if( !m_thread ) ret = Kita::Access::deleteLog( m_thread, parent );
330 if(ret) initPrivate();
337 bool DatInfo::isLoadingNow(){
339 QMutexLocker locker( &m_mutex );
347 void DatInfo::stopLoading(){
349 /* Don't lock the mutex here !!!
350 It will cause deadlock , because
351 Kita::Access::stopJob() calls KitaThreadView::slotFinishLoad() back,
352 then slotFinishLoad calls another functions in DatInfo. */
353 if ( m_access == NULL ) return;
354 if (! m_nowLoading ) return;
362 /*---------------------------------------------------*/
363 /* locking , unlocking functions */
365 /* If m_lock is not 0, DatManager can't delete this. */
366 /* Don't forget to call unlock() after locking this. */
368 /* They are public */
372 QMutexLocker locker( &m_mutex );
377 void DatInfo::unlock()
379 QMutexLocker locker( &m_mutex );
384 int DatInfo::isLocked()
386 QMutexLocker locker( &m_mutex );
392 /*------------------------------------------------------*/
393 /* get subject, linedata, id, body, name, HTML, etc. */
395 /* They are public */
397 const QString& DatInfo::getSubject()
399 QMutexLocker locker( &m_mutex );
404 const QString& DatInfo::getRawDat()
406 QMutexLocker locker( &m_mutex );
411 const QString& DatInfo::getDat( int num )
413 QMutexLocker locker( &m_mutex );
415 if ( num <= 0 || KITA_MAXRES <= num ) return QString::null;
416 if ( ! m_resDatVec[ num ].set ) return QString::null;
418 return m_resDatVec[ num ].linestr;
421 const QString& DatInfo::getId( int num )
423 QMutexLocker locker( &m_mutex );
424 if(!parseDat(num)) return QString::null;
426 return m_resDatVec[ num ].id;
429 const QString& DatInfo::getBody( int num )
431 QMutexLocker locker( &m_mutex );
432 if(!parseDat(num)) return QString::null;
434 return m_resDatVec[ num ].body;
437 const QString& DatInfo::getName( int num )
439 QMutexLocker locker( &m_mutex );
440 if(!parseDat(num)) return QString::null;
442 return m_resDatVec[ num ].name;
445 /* plain (parsed) strings of name */
446 QString DatInfo::getPlainName( int num )
448 QMutexLocker locker( &m_mutex );
449 if(!parseDat(num)) return QString::null;
451 return m_resDatVec[ num ].parsedName;
455 /* plain (parsed) strings of body */
456 QString DatInfo::getPlainBody(int num)
458 QMutexLocker locker( &m_mutex );
459 if(!parseDat(num)) return QString::null;
462 QString line = m_resDatVec[ num ].body;
464 ParseMisc::parseBODYdatText(PARSEMODE_TEXT,line,bodytext);
470 /* plain (parsed) strings of title */
471 QString DatInfo::getPlainTitle(int num)
473 QMutexLocker locker( &m_mutex );
474 if(!parseDat(num)) return QString::null;
476 bool showAddr = KitaConfig::showMailAddress();
478 ParseMisc::parseTITLEdatText(PARSEMODE_TEXT,num,showAddr,m_resDatVec[ num ],titletext);
484 /*-----------------------------------------*/
488 /* Note that this function checks Abone internally. */ /* public */
489 QString DatInfo::getHtml(int startnum, int endnum)
491 QMutexLocker locker( &m_mutex );
493 QString retstr = QString::null;
494 bool showAddr = KitaConfig::showMailAddress();
496 for(int num = startnum; num <= endnum; num++){
498 if(!parseDat(num)) continue;
499 if(checkAbonePrivate(num)) retstr += aboneHTML( num );
500 else if(m_resDatVec[ num ].broken) retstr += brokenHTML( num );
501 else retstr += ParseMisc::ResDatToHtml(m_resDatVec[ num ], num, showAddr );
508 /* return HTML strings that have ID = strid. */
509 /* Note that this function checks Abone internally. */ /* public */
510 QString DatInfo::getHtmlByID(const QString& strid, int &count )
512 QMutexLocker locker( &m_mutex );
514 QString retstr = QString::null;
515 bool showAddr = KitaConfig::showMailAddress();
519 for ( int i = 1; i <= m_maxNum; i++ ){
521 if(!parseDat(i)) continue;
523 if(m_resDatVec[i].id == strid){
525 if(checkAbonePrivate(i)) retstr += aboneHTML(i);
526 else if(m_resDatVec[ i ].broken) retstr += brokenHTML(i);
527 else retstr += ParseMisc::ResDatToHtml(m_resDatVec[i], i, showAddr);
536 QString DatInfo::aboneHTML(int num){
538 QString tmpstr = QString( "<dl><dt>" );
539 tmpstr += QString().setNum( num ) + " " + ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
540 tmpstr += "</dt><dd>";
541 tmpstr += ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );;
542 tmpstr += "<br/><br/></dd></dl>";
549 QString DatInfo::brokenHTML(int num){
551 QString tmpstr = QString( "<dl><dt>" );
552 tmpstr += QString().setNum( num ) + " " + ParseMisc::utf8ToUnicode( KITAUTF8_NAME );
553 tmpstr += "</dt><dd>";
554 tmpstr += ParseMisc::utf8ToUnicode( KITAUTF8_KOWARE );;
555 tmpstr += "<br/><br/></dd></dl>";
561 /*-------------------------------*/
562 /* Get HTML document of res tree.*/
563 /* For example, when rootnum = 1,
569 |-->>20, and return count = 3. */
571 /* Note that this function checks Abone internally. */ /* public */
572 QString DatInfo::getTreeByRes(const int rootnum, int& count)
574 QMutexLocker locker( &m_mutex );
575 return getTreeByResPrivate(rootnum,FALSE,count);
578 /*---------------------------------------*/
579 /* Get HTML document of reverse res tree.*/
580 /* For example, when rootnum = 10,
586 |-->>6, and returns count = 3. */
588 /* Note that this function checks Abone internally. */ /* public */
589 QString DatInfo::getTreeByResReverse(const int rootnum, int& count)
591 QMutexLocker locker( &m_mutex );
592 return getTreeByResPrivate(rootnum,TRUE,count);
597 QString DatInfo::getTreeByResPrivate(
599 bool reverse, /* reverse search */
602 QString tmp = QString().setNum( rootnum );
603 QString retstr = "<a href=\"#" + tmp + "\">>>" + tmp + "</a><br>";
605 retstr += getTreeByResCore(rootnum,reverse,count,"");
611 QString DatInfo::getTreeByResCore(
613 bool reverse, /* reverse search */
614 int& count, QString prestr)
616 if(!parseDat(rootnum)) return QString::null;
617 if( checkAbonePrivate(rootnum) ) return QString::null;
619 QString retstr = QString::null ;
621 QStringList strlists;
625 /* collect responses that have anchor to rootnum */
626 for ( int i = rootnum+1; i <= m_maxNum; i++ ){
627 if(checkAbonePrivate( i ) ) continue;
628 if(checkRes(i,rootnum)){
630 strlists += QString().setNum( i );
635 else { /* collect responses for which rootnum has anchors */
638 AncList& anclist = m_resDatVec[ rootnum ].anclist;
639 for ( AncList::iterator it = anclist.begin(); it != anclist.end(); ++it ){
640 for( int i = (*it).from; i <= QMIN(rootnum-1,(*it).to) ; i++){
641 if(checkAbonePrivate(i) ) continue;
643 strlists += QString().setNum( i );
648 /* make HTML document */
651 for ( QStringList::iterator it = strlists.begin(); it != strlists.end(); ++it ){
653 if((*it) == strlists.last()) tmpstr = m_framestr3; /* 'L' */
654 else tmpstr = m_framestr2; /* '|-' */
656 retstr += prestr + tmpstr + "<a href=\"#" + (*it) + "\">>>" + (*it) + "</a><br>";
658 /* call myself recursively */
661 if((*it) == strlists.last()) tmpstr += m_spacestr + m_spacestr + m_spacestr; /* " " */
662 else tmpstr += m_framestr1 + m_spacestr; /* "| " */
663 retstr += getTreeByResCore((*it).toInt(),reverse,tmpnum,tmpstr);
673 /*----------------------------------------------*/
674 /* Check if No.num has anchors to No.target */
675 /* For exsample, if target = 4, and No.num have
676 an anchor >>4, or >>2-6, etc.,
677 then return TRUE. */ /* private */
678 bool DatInfo::checkRes(const int num, const int target )
680 if(! parseDat(num)) return FALSE;
683 AncList& anclist = m_resDatVec[ num ].anclist;
685 for ( AncList::iterator it = anclist.begin(); it != anclist.end(); ++it ){
686 if ( target >= (*it).from && target <= (*it).to ) return TRUE;
694 /*--------------------------*/
695 /* set AncList */ /* private */
697 /* This function sets anchor list.
698 For example, a res has anchors >>2-3 and >>4, then
705 void DatInfo::setAncList(int num){
707 if(! parseDat(num)) return;
708 if( m_resDatVec[ num ].setAnclist ) return;
710 m_resDatVec[ num ].setAnclist = TRUE;
717 AncList& anclist = m_resDatVec[ num ].anclist;
720 QString line = m_resDatVec[ num ].body;
722 /* remove HTML tags */
723 QRegExp rex( "<[^>]*>" );
726 const QChar *chpt = line.unicode();
728 unsigned int length = line.length();
731 for ( i = 0 ; i < length ; i++ ) {
733 if( chpt[ i ].unicode() == UTF16_BRACKET || /* > */
734 (chpt[ i] == '&' && chpt[ i+1] == 'g' && chpt[ i+2] == 't' && chpt[ i+3] == ';') /* ">" */
736 while(ParseMisc::parseResAnchor(chpt+i,length-i,linkstr,refNum,pos)){
737 if(refNum[1] < refNum[0]) refNum[1] = refNum[0];
738 anctmp.from = refNum[0];
739 anctmp.to = refNum[1];
749 line = m_resDatVec[ num ].name;
750 chpt = line.unicode();
752 length = line.length();
754 while(ParseMisc::parseResAnchor(chpt+i,length-i,linkstr,refNum,pos)){
755 if(refNum[1] < refNum[0]) refNum[1] = refNum[0];
756 anctmp.from = refNum[0];
757 anctmp.to = refNum[1];
765 /*----------------------------------*/
766 /* Get DOM element */
768 /* This function returns the element
771 This function checks Abone
772 internally. So, if the res is
773 aboned,the output is "abone" node.
775 If the res is broken, the output
779 bool DatInfo::getDomElement(
783 DOM::HTMLDocument& hdoc, /* root of HTML document */
786 DOM::Element& retelm)
789 QMutexLocker locker( &m_mutex );
790 if(!parseDat(num)) return FALSE;
793 QString status = "normal";
794 DOM::Element bodynode, titlenode, tmpelm;
795 bool showAddr = KitaConfig::showMailAddress();
796 bool showAA = KitaConfig::showAA();
797 bool abone = checkAbonePrivate( num );
799 RESDAT& resdat = m_resDatVec[ num ];
801 if ( !resdat.broken && !abone ){
804 titlenode = hdoc.createElement( "DT" );
805 ParseMisc::parseTITLEdat(PARSEMODE_DOM,hdoc,num,showAddr,resdat,titlenode,tmpstr);
808 bodynode = hdoc.createElement( "DD" );
810 /* put the span node at the head of each line */
813 tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
815 tmpelm.setAttribute( "style", "color: white" );
816 tmpelm.appendChild( hdoc.createTextNode( "" ) );
820 ParseMisc::parseBODYdat(PARSEMODE_DOM,resdat.body,hdoc,showAA,bodynode,tmpstr);
823 } else { /* abone or data is broken */
828 if(abone){ /* "abone" node */
829 namestr = ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
830 bodystr = ParseMisc::utf8ToUnicode( KITAUTF8_ABONE );
833 else{ /* "broken" node */
834 namestr = ParseMisc::utf8ToUnicode( KITAUTF8_NAME );
835 bodystr = ParseMisc::utf8ToUnicode( KITAUTF8_KOWARE );
840 titlenode = hdoc.createElement( "DT" );
841 titlenode.appendChild( hdoc.createTextNode(
842 QString().setNum( num ) + " " + namestr ) );
845 bodynode = hdoc.createElement( "DD" );
846 tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
848 tmpelm.setAttribute( "style", "color: red" );
849 tmpelm.appendChild( hdoc.createTextNode( bodystr ) );
854 bodynode.appendChild( hdoc.createElement( "BR" ) );
855 bodynode.appendChild( hdoc.createElement( "BR" ) );
857 /*-----------------------------*/
859 retelm = hdoc.createElement( "DIV" );
861 retelm.setAttribute( "kita_type", "res" );
862 retelm.setAttribute( "kita_status", status );
863 retelm.setAttribute( "id", QString().setNum( num ) );
864 retelm.setAttribute( "kita_rname", resdat.name );
865 retelm.setAttribute( "kita_rid", resdat.id );
867 tmpelm = retelm.appendChild( hdoc.createElement( "DL" ) );
869 tmpelm.appendChild( titlenode );
870 tmpelm.appendChild( bodynode );
879 /*-----------------------*/
880 /* several information */
883 int DatInfo::getMaxResNumber()
885 QMutexLocker locker( &m_mutex );
891 /* return number of responses that have ID = strid. */
892 /* Note that this function checks Abone internally. */ /* public */
893 int DatInfo::getNumByID( const QString& strid )
895 QMutexLocker locker( &m_mutex );
899 for ( int i = 1; i <= m_maxNum; i++ ) {
901 if( !parseDat(i) ) continue;
902 if( checkAbonePrivate( i ) ) continue;
904 if ( m_resDatVec[i].id == strid ) count++;
911 int DatInfo::getKokoyonNum()
913 QMutexLocker locker( &m_mutex );
915 return QMIN(m_kokoyonNum, m_maxNum);
919 void DatInfo::setKokoyonNum(int num)
921 QMutexLocker locker( &m_mutex );
923 num = QMIN(num, m_maxNum);
926 KitaThreadInfo::setReadNum( m_datURL.prettyURL(), num );
930 int DatInfo::getDatSize()
932 QMutexLocker locker( &m_mutex );
934 return m_rawData.length();
939 bool DatInfo::isResValid(int num)
941 QMutexLocker locker( &m_mutex );
943 return parseDat(num);
947 bool DatInfo::isBroken()
949 QMutexLocker locker( &m_mutex );
955 bool DatInfo::isResBroken(int num)
957 QMutexLocker locker( &m_mutex );
958 if(!parseDat(num)) return FALSE;
960 return m_resDatVec[ num ].broken;
963 /* ID = strid ? */ /* public */
964 bool DatInfo::checkID(const QString& strid, int num )
966 QMutexLocker locker( &m_mutex );
967 if(!parseDat(num)) return FALSE;
969 if(m_resDatVec[num].id == strid) return TRUE;
975 /* Are keywords included ? */ /* public */
976 bool DatInfo::checkWord(QStringList& stlist, /* list of keywords */
978 bool checkOR /* AND or OR search */
981 QMutexLocker locker( &m_mutex );
982 if(!parseDat(num)) return FALSE;
984 QString str_text = m_resDatVec[ num ].body;
986 for ( QStringList::iterator it = stlist.begin(); it != stlist.end(); ++it ) {
988 QRegExp regexp( (*it) );
989 regexp.setCaseSensitive( FALSE );
991 if ( checkOR ) { /* OR */
992 if ( str_text.find( regexp, 0 ) != -1 ) {
996 if ( str_text.find( regexp, 0 ) == -1 ) return FALSE;
1000 if ( checkOR ) return FALSE;
1006 bool DatInfo::isMarked( int num )
1008 QMutexLocker locker( &m_mutex );
1010 return m_resDatVec[ num ].marked;
1015 void DatInfo::setMark( int num, bool mark )
1017 QMutexLocker locker( &m_mutex );
1019 m_resDatVec[ num ].marked = mark;
1025 /*--------------------------------*/
1026 /* abone functions */
1029 /*-----------------------*/
1032 /* call this when config
1033 of abone changed. */ /* public */
1035 void DatInfo::resetAbone()
1037 QMutexLocker locker( &m_mutex );
1039 return resetAbonePrivate();
1043 void DatInfo::resetAbonePrivate()
1045 for ( int i = 1; i < KITA_MAXRES; i++ ) m_resDatVec[ i ].checkAbone = FALSE;
1047 m_aboneByID = ( !KitaConfig::aboneIDList().empty() );
1048 m_aboneByName = ( !KitaConfig::aboneNameList().empty() );
1049 m_aboneByBody = ( !KitaConfig::aboneWordList().empty() );
1050 m_aboneByRes = m_aboneByID | m_aboneByName | m_aboneByBody;
1055 /* check abone */ /* public */
1057 bool DatInfo::checkAbone(int num)
1059 QMutexLocker locker( &m_mutex );
1061 return checkAbonePrivate(num);
1066 bool DatInfo::checkAbonePrivate(int num)
1068 if(!parseDat(num)) return FALSE;
1070 if ( m_resDatVec[ num ].checkAbone ) return m_resDatVec[ num ].abone;
1072 m_resDatVec[ num ].checkAbone = TRUE;
1073 bool checktmp = FALSE;
1076 checktmp = checkAboneCore(m_resDatVec[ num ].id,KitaConfig::aboneIDList());
1078 if(!checktmp && m_aboneByName )
1079 checktmp = checkAboneCore(m_resDatVec[ num ].parsedName,KitaConfig::aboneNameList());
1081 if(!checktmp && m_aboneByBody )
1082 checktmp = checkAboneCore(m_resDatVec[ num ].body,KitaConfig::aboneWordList());
1084 if(!checktmp && m_aboneByRes )
1087 AncList& anclist = m_resDatVec[ num ].anclist;
1089 for ( AncList::iterator it = anclist.begin();
1090 it != anclist.end() && !checktmp ; ++it ){
1092 int refNum = (*it).from;
1093 int refNum2 = (*it).to;
1095 /* I don't want to enter loop... */
1096 if ( refNum >= num ) continue;
1097 if ( refNum2 >= num ) refNum2 = num - 1;
1099 for (int i = refNum; i <= refNum2; i++ ){
1100 if (checkAbonePrivate(i)){
1108 m_resDatVec[ num ].abone = checktmp;
1110 return m_resDatVec[ num ].abone;
1114 bool DatInfo::checkAboneCore(const QString& str, QStringList& strlist)
1116 if(strlist.count()){
1119 for ( QStringList::iterator it = strlist.begin();
1120 it != strlist.end(); ++it ) {
1121 i = str.find( ( *it ) );
1133 /*---------------------------------------*/
1134 /* simple parsing function */
1136 /* This function parses struct RESDAT by
1137 ParseMisc::parseResDat. In short, this
1138 splits the raw date into name, id,
1139 date, and bodytext, etc.
1141 Note that this function keeps data as
1142 the raw data. So, you need to parse them
1143 later by getPlainBody, getHtml,
1146 bool DatInfo::parseDat( int num ){
1148 if ( num <= 0 || KITA_MAXRES <= num ) return FALSE;
1149 if( m_resDatVec[ num ].parsed ) return TRUE;
1152 if( !ParseMisc::parseResDat( m_resDatVec[ num ], tmpstr ) ) return FALSE;
1155 if ( m_subject == QString::null && tmpstr != QString::null ){
1157 Kita::Thread::setName( m_datURL.prettyURL(), m_subject );