1 /***************************************************************************
2 * Copyright (C) 2004 by Kita Developers *
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 ***************************************************************************/
13 #include <QtCore/QDateTime>
14 #include <QtCore/QList>
15 #include <QtCore/QObject>
16 #include <QtCore/QVector>
20 #include "threadindex.h"
25 /* return val of DatInfo::getHTML() */
42 /* Data Base of anchor
44 For example, No.5 res has name = "foo", id "id1234", and anchors >>2-3 and >>4, then,
46 m_resDatVec[5].name = "foo",
47 m_resDatVec[5].id = "id1234",
48 m_resDatVec[5].anclist[0].from = 2,
49 m_resDatVec[5].anclist[0].to = 3,
50 m_resDatVec[5].anclist[1].from = 4,
51 m_resDatVec[5].anclist[1].to = 4.
60 typedef QList<ANCNUM> AncList;
63 /* Data Base of response */
67 QString linestr; /* raw line data */
83 AncList anclist; /* anchor list. See above. */
85 bool checkAbone; /* Is abone checked ? */
88 /* Is this res responsed by other one? */
91 typedef QVector<RESDAT> ResDatVec;
101 /*-----------------------*/
103 class KDE_EXPORT DatInfo : public QObject
107 /* pointer of Thread class */
110 /* basic information */
112 ThreadIndex m_threadIndex;
114 ResDatVec m_resDatVec;
119 OfflawAccess* m_access2;
130 /* japanese strings */
132 QString m_framestr1; /* '|' */
133 QString m_framestr2; /* '|-' */
134 QString m_framestr3; /* 'L' */
136 /*-------------------------------*/
141 DatInfo(const KUrl& url);
144 const KUrl& url() const;
147 bool updateCache(const QObject* parent);
148 int getResponseCode() const;
149 int getServerTime() const;
151 bool isLoadingNow() const;
152 void stopLoading() const;
155 QString getDat(int num);
156 QString getId(int num);
157 QString getPlainName(int num);
158 QString getPlainTitle(int num);
159 QString getPlainBody(int num);
162 int getHTML(int num, bool checkAbone, QString& titleHTML,
164 QString getHTMLString(int startnum, int endnum,
165 bool checkAbone = true);
166 QString getHtmlById(const QString& strid, int &count);
167 QString getTreeByRes(int rootnum, int& count);
168 QString getTreeByResReverse(int rootnum, int& count);
171 int getResNum() const;
172 int getReadNum() const;
173 int getViewPos() const;
174 int getNumById(const QString& strid);
175 int getDatSize() const;
177 /* several information */
178 bool isResponsed (int num) const;
179 bool isResValid(int num);
180 bool isBroken() const;
181 bool isResBroken(int num);
182 bool checkId(const QString& strid, int num);
183 bool checkWord(const QStringList& stlist, int num, bool checkOr);
184 bool isOpened() const;
185 void setOpened(bool isOpened);
188 bool checkAbone(int num);
191 /*-------------------------*/
195 void initPrivate(bool loadCache = true);
196 void resetResDat(RESDAT& resdat) const;
197 void increaseResDatVec(int delta);
198 void deleteAccessJob();
201 bool copyOneLineToResDat(const QString& line);
204 int getHTMLPrivate(int num, bool checkAbone, QString& titleHTML,
206 void getHtmlOfOneRes(int num, bool checkAbone, QString& html);
207 QString getTreeByResPrivate(int rootnum, bool reverse, int& count);
208 QString getTreeByResCore(int rootnum, bool reverse, int& count,
209 const QString& prestr);
210 bool checkRes(int num, int target);
213 void resetAbonePrivate();
214 bool checkAbonePrivate(int num);
215 bool checkAboneCore(const QString& str, const QStringList& strlist)
218 /* parsing functions */
219 bool parseDat(int num);
221 void createTitleHtml(RESDAT& resdat, QString& titleHtml);
223 DatInfo(const DatInfo&);
224 DatInfo& operator=(const DatInfo&);
225 /*----------------------------*/
229 void slotReceiveData(const QStringList& lineList);
230 void slotFinishLoad();