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 ***************************************************************************/
16 #include <qvaluevector.h>
17 #include <qdatetime.h>
34 /* ResDatVec is the Database for responses. */
35 /* For example, No.5 res has name = "foo", id "id1234", and anchors >>2-3 and >>4,
38 m_resDatVec[5].name = "foo",
39 m_resDatVec[5].id = "id1234",
40 m_resDatVec[5].anclist[0].from = 2,
41 m_resDatVec[5].anclist[0].to = 3,
42 m_resDatVec[5].anclist[1].from = 4,
43 m_resDatVec[5].anclist[1].to = 4.
50 typedef QValueList<ANCNUM> AncList;
52 /* Data of one response */
55 bool set; /* Is linestr set ? */
57 QString linestr; /* raw line strings */
61 bool parsed; /* Is dat parsed ? */
63 bool broken; /* This dat is broken */
74 bool setAnclist; /* Is anclist set ? */
76 AncList anclist; /* anchor list. See also setAncList() */
80 bool checkAbone; /* Is abone checked ? */
85 typedef QValueVector<RESDAT> ResDatVec;
88 /*-----------------------*/
90 class DatInfo : public QObject
96 /* basic information */
102 ResDatVec m_resDatVec;
104 int m_kokoyonNum; /* kokomade yonda */
112 /* japanese strings */
114 QString m_framestr1; /* '|' */
115 QString m_framestr2; /* '|-' */
116 QString m_framestr3; /* 'L' */
118 /*-------------------------------*/
123 DatInfo( const KURL& url );
129 bool updateCache(const QObject* parent);
130 int getResponseCode();
132 bool deleteCache(QWidget* parent);
142 const QString& getSubject();
143 const QString& getRawDat();
144 const QString& getDat( int num );
145 const QString& getId( int num );
146 const QString& getName( int num );
147 const QString& getBody( int num );
148 QString getPlainBody(int num);
149 QString getPlainTitle(int num);
152 QString getHtml(int startnum, int endnum);
153 QString getHtmlByID(const QString& strid, int &count );
154 QString getTreeByRes(const int rootnum, int& count );
157 int getMaxResNumber();
158 int getNumByID( const QString& strid );
160 void setKokoyonNum(int num);
163 /* several informations */
164 bool isResValid(int num);
166 bool isResBroken(int num);
167 bool checkID(const QString& strid, int num );
168 bool checkWord(QStringList& stlist, int num, bool checkOR);
171 bool checkAbone(int num);
173 /* Wrapper functions for Thread */
174 const QString thread_datID();
175 const QString& thread_name();
176 const QString& thread_boardName();
177 const QString thread_url();
178 const QString thread_boardURL();
179 const QString thread_boardID();
181 /*-------------------------*/
186 void resetResDat(RESDAT& resdat);
187 void deleteAccessJob();
190 void copyRawDataToBuffer(const QString& rawData);
191 bool setDat( const QString& line, int num );
194 QString getTreeByResPrivate(const int rootnum, int& count, QString prestr);
195 bool checkRes(const int num, const int target );
196 void setAncList(int num);
199 bool checkAbonePrivate(int num);
200 bool checkAboneCore(const QString& str, QStringList& strlist);
202 /* parsing funtions */
203 bool parseDat( int num );
204 QString toHtml(RESDAT& resdat, int num, bool showMailAddress ) const;
205 QString linkedAddress(RESDAT& resdat, bool showMailAddress ) const;
206 QString linkedBody(RESDAT& resdat) const;
207 QString getDateId(RESDAT&) const;
209 /*----------------------------*/
213 void slotReceiveData(const QString& newLine);
214 void slotFinishLoad();