1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/***************************************************************************
* Copyright (C) 2004 by Paulo Moura Guedes *
* [email protected] *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef LINKSTATUS_H
#define LINKSTATUS_H
#include "../parser/http.h"
#include "../utils/mvector.h"
#include <kurl.h>
#include <klocale.h>
#include <kdebug.h>
class TreeView;
class TreeViewItem;
#include <tqstring.h>
#include <tqobject.h>
#include <tqvaluevector.h>
class QDomElement;
#include <vector>
#include <iostream>
using namespace std;
class Node;
class LinkStatus
{
public:
enum Status {
UNDETERMINED,
SUCCESSFULL,
BROKEN,
HTTP_REDIRECTION,
HTTP_CLIENT_ERROR,
HTTP_SERVER_ERROR,
TIMEOUT,
NOT_SUPPORTED,
MALFORMED
};
LinkStatus();
LinkStatus(KURL const& absolute_url);
LinkStatus(Node* node, LinkStatus* parent);
~LinkStatus();
void save(TQDomElement& element) const;
void reset();
void setRootUrl(KURL const& url);
void setStatus(Status status);
void setDepth(uint depth);
void setParent(LinkStatus* parent);
void setOriginalUrl(TQString const& url_original);
void setLabel(TQString const& label);
void setAbsoluteUrl(KURL const& url_absoluto);
void setDocHtml(TQString const& doc_html);
void setHttpHeader(HttpResponseHeader const& cabecalho_http);
void setStatusText(TQString const& statusText); // FIXME Legacy. This should be eliminated in favor of LinkStatus::Status
void setError(TQString const& error);
void setIsRoot(bool flag);
void setErrorOccurred(bool houve_error);
void setIsRedirection(bool e_redirection);
void setRedirection(LinkStatus* redirection);
void setNode(Node* node);
void setChildrenNodes(vector<Node*> const& nodes);
void addChildNode(Node* node);
void reserveMemoryForChildrenNodes(int n);
void setChecked(bool flag);
void setExternalDomainDepth(int p);
void setOnlyCheckHeader(bool flag);
void setMalformed(bool flag = true);
void setHasBaseURI(bool flag = true);
void setHasHtmlDocTitle(bool flag = true);
void setBaseURI(KURL const& base_url);
void setHtmlDocTitle(TQString const& title);
void setIgnored(bool flag = true);
void setMimeType(TQString const& mimetype);
void setIsErrorPage(bool flag);
void setIsLocalRestrict(bool flag);
void setTreeViewItem(TreeViewItem* tree_view_item);
void addReferrer(KURL const& url);
KURL const& rootUrl() const;
Status const& status() const;
uint depth() const;
bool local() const; // linkstatus.paradigma.co.pt == paradigma.co.pt
bool isLocalRestrict() const; // linkstatus.paradigma.co.pt != paradigma.co.pt
LinkStatus const* parent() const;
TQString const& originalUrl() const;
TQString const& label() const;
KURL const& absoluteUrl() const;
TQString const& docHtml() const;
HttpResponseHeader const& httpHeader() const;
HttpResponseHeader& httpHeader();
TQString statusText() const; // FIXME Legacy. This should be eliminated in favor of LinkStatus::Status
TQString const& error() const;
bool isRoot() const;
bool errorOccurred() const;
bool isRedirection() const;
LinkStatus* redirection() const;
Node* node() const;
vector<Node*> const& childrenNodes() const;
TQString const toString() const;
bool checked() const;
int externalDomainDepth() const;
bool onlyCheckHeader() const;
bool malformed() const;
bool hasBaseURI() const;
bool hasHtmlDocTitle() const;
KURL const& baseURI() const;
TQString const& htmlDocTitle() const;
bool ignored() const;
bool redirectionExists(KURL const& url) const; // to avoid cyclic links
TQString mimeType() const;
bool isErrorPage() const;
TreeViewItem* treeViewItem() const;
TQValueVector<KURL> const& referrers() const;
static LinkStatus* lastRedirection(LinkStatus* ls);
private:
/**
Load some atributes in function of his parent node.
*/
void loadNode();
private:
KURL root_url_; // The URL which made the search start
Status status_;
int depth_;
int external_domain_depth_; // Para se poder escolher explorar domains diferentes ate n depth
TQString original_url_;
TQString label_;
KURL absolute_url_;
TQString doc_html_;
HttpResponseHeader http_header_;
TQString status_text_; // FIXME Legacy. This should be eliminated in favor of LinkStatus::Status
TQString error_;
bool is_root_;
bool error_occurred_;
bool is_redirection_;
vector<Node*> children_nodes_;
LinkStatus* parent_;
LinkStatus* redirection_;
bool checked_;
bool only_check_header_;
bool malformed_;
Node* node_;
bool has_base_URI_;
bool has_html_doc_title_;
KURL base_URI_;
TQString html_doc_title_;
bool ignored_;
TQString mimetype_;
bool is_error_page_;
bool is_local_restrict_;
TreeViewItem* tree_view_item_;
TQValueVector<KURL> referrers_;
};
#include "../parser/url.h"
#include "linkstatus_impl.h"
#endif
|