From 7f0d550a7c96c4a8b74326f37ea9427a6edb48f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 24 Mar 2014 23:37:40 +0100 Subject: [PATCH] HaikuDepot: Forgot to add the new files. --- src/apps/haikudepot/ConnectionTest.cpp | 109 +++++++++++++++++++++++++ src/apps/haikudepot/ConnectionTest.h | 21 +++++ 2 files changed, 130 insertions(+) create mode 100644 src/apps/haikudepot/ConnectionTest.cpp create mode 100644 src/apps/haikudepot/ConnectionTest.h diff --git a/src/apps/haikudepot/ConnectionTest.cpp b/src/apps/haikudepot/ConnectionTest.cpp new file mode 100644 index 0000000000..9c95fa8f79 --- /dev/null +++ b/src/apps/haikudepot/ConnectionTest.cpp @@ -0,0 +1,109 @@ +/* + * Copyright 2014, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "ConnectionTest.h" + +#include + +#include +#include +#include +#include +#include + + +class ProtocolListener : public BUrlProtocolListener { + virtual void ConnectionOpened(BUrlRequest* caller) + { + printf("ConnectionOpened(%p)\n", caller); + } + + virtual void HostnameResolved(BUrlRequest* caller, const char* ip) + { + printf("HostnameResolved(%p): %s\n", caller, ip); + } + + virtual void ResponseStarted(BUrlRequest* caller) + { + printf("ResponseStarted(%p)\n", caller); + } + + virtual void HeadersReceived(BUrlRequest* caller) + { + printf("HeadersReceived(%p)\n", caller); + } + + virtual void DataReceived(BUrlRequest* caller, const char* data, + ssize_t size) + { + printf("DataReceived(%p): %ld bytes\n", caller, size); + } + + virtual void DownloadProgress(BUrlRequest* caller, ssize_t bytesReceived, + ssize_t bytesTotal) + { + printf("DownloadProgress(%p): %ld/%ld\n", caller, bytesReceived, + bytesTotal); + } + + virtual void UploadProgress(BUrlRequest* caller, ssize_t bytesSent, + ssize_t bytesTotal) + { + printf("UploadProgress(%p): %ld/%ld\n", caller, bytesSent, bytesTotal); + } + + virtual void RequestCompleted(BUrlRequest* caller, bool success) + { + printf("RequestCompleted(%p): %d\n", caller, success); + } + + virtual void DebugMessage(BUrlRequest* caller, + BUrlProtocolDebugMessage type, const char* text) + { + printf("DebugMessage(%p): %s\n", caller, text); + } +}; + + +ConnectionTest::ConnectionTest() + : + BApplication("application/x-vnd.Haiku-HaikuDepot-ConnectionTest") +{ +} + + +ConnectionTest::~ConnectionTest() +{ +} + + +void +ConnectionTest::ReadyToRun() +{ + printf("Connecting...\n"); + + BUrl url("https://depot.haiku-os.org"); + + ProtocolListener listener; + BUrlContext context; + + BHttpRequest request(url, true, "HTTP", &listener, &context); + + + thread_id thread = request.Run(); + wait_for_thread(thread, NULL); + + PostMessage(B_QUIT_REQUESTED, this); +} + + +int +main(int argc, char* argv[]) +{ + ConnectionTest().Run(); + return 0; +} + + diff --git a/src/apps/haikudepot/ConnectionTest.h b/src/apps/haikudepot/ConnectionTest.h new file mode 100644 index 0000000000..e07f6d82c3 --- /dev/null +++ b/src/apps/haikudepot/ConnectionTest.h @@ -0,0 +1,21 @@ +/* + * Copyright 2014, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef CONNECTION_TEST_H +#define CONNECTION_TEST_H + + +#include + + +class ConnectionTest : public BApplication { +public: + ConnectionTest(); + virtual ~ConnectionTest(); + + virtual void ReadyToRun(); +}; + + +#endif // CONNECTION_TEST_H