diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-07 14:36:10 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-07 14:36:10 +0200 |
commit | 8f30657390dd220ce3dd0f747281edbf585e639d (patch) | |
tree | 4a57e7813293b5d576716a7111a06c64ab87b0da /Applications/Downloader | |
parent | c7365a00f8508d387395c6f0f9fd4d07ee34aa73 (diff) | |
download | serenity-8f30657390dd220ce3dd0f747281edbf585e639d.zip |
Start working on a Downloader app and backing classes in LibGUI.
LibGUI is slowly becoming LibKitchensink but I'm okay with this for now.
Diffstat (limited to 'Applications/Downloader')
-rw-r--r-- | Applications/Downloader/.gitignore | 3 | ||||
-rw-r--r-- | Applications/Downloader/Makefile | 32 | ||||
-rw-r--r-- | Applications/Downloader/main.cpp | 30 |
3 files changed, 65 insertions, 0 deletions
diff --git a/Applications/Downloader/.gitignore b/Applications/Downloader/.gitignore new file mode 100644 index 0000000000..bdc2af7797 --- /dev/null +++ b/Applications/Downloader/.gitignore @@ -0,0 +1,3 @@ +*.o +*.d +Downloader diff --git a/Applications/Downloader/Makefile b/Applications/Downloader/Makefile new file mode 100644 index 0000000000..4138c392f9 --- /dev/null +++ b/Applications/Downloader/Makefile @@ -0,0 +1,32 @@ +OBJS = \ + main.o + +APP = Downloader + +STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation +WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough +FLAVOR_FLAGS = -fno-exceptions -fno-rtti +OPTIMIZATION_FLAGS = -Os +INCLUDE_FLAGS = -I../../Servers -I../.. -I. -I../../LibC + +DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND + +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-pc-serenity-g++ +LD = i686-pc-serenity-g++ +AR = i686-pc-serenity-ar +LDFLAGS = -L../../LibC -L../../LibGUI + +all: $(APP) + +$(APP): $(OBJS) + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc + +.cpp.o: + @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< + +-include $(OBJS:%.o=%.d) + +clean: + @echo "CLEAN"; rm -f $(APPS) $(OBJS) *.d + diff --git a/Applications/Downloader/main.cpp b/Applications/Downloader/main.cpp new file mode 100644 index 0000000000..dcca9f086b --- /dev/null +++ b/Applications/Downloader/main.cpp @@ -0,0 +1,30 @@ +#include <LibGUI/GApplication.h> +#include <LibGUI/GHttpRequest.h> +#include <LibGUI/GHttpResponse.h> +#include <LibGUI/GNetworkJob.h> +#include <stdio.h> + +int main(int argc, char** argv) +{ + GApplication app(argc, argv); + + GHttpRequest request; + request.set_hostname("www.google.com"); + request.set_path("/"); + + auto job = request.schedule(); + job->on_finish = [&job] (bool success) { + if (!success) { + dbgprintf("on_finish: request failed :(\n"); + return; + } + auto& response = static_cast<const GHttpResponse&>(*job->response()); + printf("on_receive: code=%d\n", response.code()); + printf("payload:\n"); + printf("%s", response.payload().pointer()); + printf("payload was %d bytes\n", response.payload().size()); + }; + + printf("Entering main loop...\n"); + return app.exec(); +} |