1 /***************************************************************************
2 * Copyright (C) 2003 by Hideki Ikemoto , (c)2004 by 421 *
3 * ikemo@users.sourceforge.jp *
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 ***************************************************************************/
16 #include <qvaluevector.h>
17 #include <qdatetime.h>
35 /* ResDatVec is the Database for responses. */
36 /* For example, No.5 res has name = "foo", id "id1234", and anchors >>2-3 and >>4,
39 m_resDatVec[5].name = "foo",
40 m_resDatVec[5].id = "id1234",
41 m_resDatVec[5].anclist[0].from = 2,
42 m_resDatVec[5].anclist[0].to = 3,
43 m_resDatVec[5].anclist[1].from = 4,
44 m_resDatVec[5].anclist[1].to = 4.
52 typedef QValueList<ANCNUM> AncList;
54 /* Data of one response */
58 bool set; /* Is linestr set ? */
60 QString linestr; /* raw line strings */
64 bool parsed; /* Is dat parsed ? */
66 bool broken; /* This dat is broken */
80 bool setAnclist; /* Is anclist set ? */
82 AncList anclist; /* anchor list. See also setAncList() */
86 bool checkAbone; /* Is abone checked ? */
91 typedef QValueVector<RESDAT> ResDatVec;
100 /*-----------------------*/
102 class DatInfo : public QObject
108 /* basic information */
114 ResDatVec m_resDatVec;
116 int m_kokoyonNum; /* kokomade yonda */
131 /* japanese strings */
133 QString m_framestr1; /* '|' */
134 QString m_framestr2; /* '|-' */
135 QString m_framestr3; /* 'L' */
137 /*-------------------------------*/
142 DatInfo( const KURL& url );
148 bool updateCache(const QObject* parent);
149 int getResponseCode();
151 bool deleteCache(QWidget* parent);
161 const QString& getSubject();
162 const QString& getRawDat();
163 const QString& getDat( int num );
164 const QString& getId( int num );
165 const QString& getName( int num );
166 const QString& getBody( int num );
167 QString getPlainName(int num);
168 QString getPlainBody(int num);
169 QString getPlainTitle(int num);
172 QString getHtml(int startnum, int endnum);
173 QString getHtmlByID(const QString& strid, int &count );
174 QString getTreeByRes(const int rootnum, int& count );
175 QString getTreeByResReverse(const int rootnum, int& count );
178 bool getDomElement(int num, DOM::HTMLDocument& hdoc, DOM::Element& retelm);
181 int getMaxResNumber();
182 int getNumByID( const QString& strid );
184 void setKokoyonNum(int num);
187 /* several informations */
188 bool isResValid(int num);
190 bool isResBroken(int num);
191 bool checkID(const QString& strid, int num );
192 bool checkWord(QStringList& stlist, int num, bool checkOR);
193 bool isMarked( int num );
194 void setMark( int num, bool mark );
197 bool checkAbone(int num);
200 /*-------------------------*/
205 void resetResDat(RESDAT& resdat);
206 void deleteAccessJob();
209 void copyRawDataToBuffer(const QString& rawData);
210 bool setDat( const QString& line, int num );
213 QString aboneHTML(int num);
214 QString brokenHTML(int num);
215 QString getTreeByResPrivate(const int rootnum,bool reverse,int& count);
216 QString getTreeByResCore(const int rootnum, bool reverse, int& count, QString prestr);
217 bool checkRes(const int num, const int target );
218 void setAncList(int num);
221 void resetAbonePrivate();
222 bool checkAbonePrivate(int num);
223 bool checkAboneCore(const QString& str, QStringList& strlist);
225 /* parsing funtions */
226 bool parseDat( int num );
228 /*----------------------------*/
232 void slotReceiveData(const QString& newLine);
233 void slotFinishLoad();