Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netrunner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sharinigma
netrunner
Commits
f54607b7
Commit
f54607b7
authored
7 years ago
by
Odilitime
Browse files
Options
Downloads
Patches
Plain Diff
move navTo into window class
parent
dbec113f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.cpp
+5
-63
5 additions, 63 deletions
src/main.cpp
with
5 additions
and
63 deletions
src/main.cpp
+
5
−
63
View file @
f54607b7
...
...
@@ -11,12 +11,13 @@ const std::unique_ptr<Window> window = std::make_unique<Window>();
//URL currentURL;
bool
setWindowContent
(
URL
const
&
url
)
{
logDebug
()
<<
"main::setWindowContent - "
<<
url
<<
std
::
endl
;
WebResource
res
=
getWebResource
(
url
);
if
(
res
.
resourceType
==
ResourceType
::
INVALID
)
{
logError
()
<<
"Invalid resource type: "
<<
res
.
raw
<<
std
::
endl
;
return
false
;
}
HTMLParser
parser
;
const
std
::
clock_t
begin
=
clock
();
std
::
shared_ptr
<
Node
>
rootNode
=
parser
.
parse
(
res
.
raw
);
...
...
@@ -26,58 +27,6 @@ bool setWindowContent(URL const& url) {
return
true
;
}
/*
void navTo(std::string url) {
logDebug() << "navTo(" << url << ")" << std::endl;
currentURL = currentURL.merge(URL(url));
logDebug() << "go to: " << currentURL << std::endl;
setWindowContent(currentURL);
//std::shared_ptr<URI> uri = parseUri(url);
//const std::shared_ptr<HTTPRequest> request = std::make_shared<HTTPRequest>(uri);
//currentURL=url;
//request->sendRequest(handleRequest);
}
*/
/*
void handleRequest(const HTTPResponse &response) {
std::cout << "main:::handleRequest - statusCode: " << response.statusCode << std::endl;
if (response.statusCode == 200) {
const std::unique_ptr<HTMLParser> parser = std::make_unique<HTMLParser>();
const std::clock_t begin = clock();
std::shared_ptr<Node> rootNode = parser->parse(response.body);
const std::clock_t end = clock();
std::cout << "Parsed document in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
window->setDOM(rootNode);
}
else if (response.statusCode == 301) {
std::string location;
if (response.properties.find("Location")==response.properties.end()) {
if (response.properties.find("location")==response.properties.end()) {
std::cout << "::handleRequest - got 301 without a location" << std::endl;
for(auto const &row : response.properties) {
std::cout << "::handleRequest - " << row.first << "=" << response.properties.at(row.first) << std::endl;
}
return;
} else {
location = response.properties.at("location");
}
} else {
location = response.properties.at("Location");
}
std::cout << "Redirect To: " << location << std::endl;
std::shared_ptr<URI> uri = parseUri(location);
const std::unique_ptr<HTTPRequest> request = std::make_unique<HTTPRequest>(uri);
request->sendRequest(handleRequest);
return;
}
else {
std::cout << "Unknown Status Code: " << response.statusCode << std::endl;
}
}
*/
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
==
1
)
{
std
::
cout
<<
"./netrunner <url|file.html> [-log <error|warning|notice|info|debug>]"
<<
std
::
endl
;
...
...
@@ -90,20 +39,13 @@ int main(int argc, char *argv[]) {
if
(
url
[
0
]
==
'/'
)
{
url
=
"file://"
+
url
;
}
//currentURL=URL(url);
window
->
currentURL
=
URL
(
argv
[
1
]);
window
->
currentURL
=
URL
(
url
);
logDebug
()
<<
"loading ["
<<
window
->
currentURL
<<
"]"
<<
std
::
endl
;
if
(
!
setWindowContent
(
window
->
currentURL
))
{
return
1
;
}
WebResource
res
=
getWebResource
(
window
->
currentURL
);
if
(
res
.
resourceType
==
ResourceType
::
INVALID
)
{
std
::
cout
<<
"Invalid resource type"
<<
std
::
endl
;
return
1
;
}
window
->
init
();
if
(
!
window
->
window
)
{
return
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment