diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-07 22:54:27 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-07 22:55:33 +0200 |
commit | 3654710c418a8972555a5d079bfebca0b1fdb8e5 (patch) | |
tree | e23a0926a53e667cb8d46e3a7a5a7317204060e8 | |
parent | b81b2a85c4b84b456630cf95fc37a0c429334164 (diff) | |
download | serenity-3654710c418a8972555a5d079bfebca0b1fdb8e5.zip |
LibIPC+Services: Support URL as a native IPC type
-rw-r--r-- | DevTools/IPCCompiler/main.cpp | 1 | ||||
-rw-r--r-- | Libraries/LibDesktop/Launcher.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibIPC/Decoder.cpp | 19 | ||||
-rw-r--r-- | Libraries/LibIPC/Decoder.h | 1 | ||||
-rw-r--r-- | Libraries/LibIPC/Encoder.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibIPC/Encoder.h | 1 | ||||
-rw-r--r-- | Services/LaunchServer/ClientConnection.cpp | 4 | ||||
-rw-r--r-- | Services/LaunchServer/ClientConnection.h | 2 | ||||
-rw-r--r-- | Services/LaunchServer/LaunchServer.ipc | 4 | ||||
-rw-r--r-- | Services/ProtocolServer/ProtocolServer.ipc | 2 |
10 files changed, 26 insertions, 16 deletions
diff --git a/DevTools/IPCCompiler/main.cpp b/DevTools/IPCCompiler/main.cpp index 4a86508d7b..92525b2acf 100644 --- a/DevTools/IPCCompiler/main.cpp +++ b/DevTools/IPCCompiler/main.cpp @@ -244,6 +244,7 @@ int main(int argc, char** argv) out() << "#pragma once"; out() << "#include <AK/BufferStream.h>"; out() << "#include <AK/OwnPtr.h>"; + out() << "#include <AK/URL.h>"; out() << "#include <AK/Utf8View.h>"; out() << "#include <LibGfx/Color.h>"; out() << "#include <LibGfx/Rect.h>"; diff --git a/Libraries/LibDesktop/Launcher.cpp b/Libraries/LibDesktop/Launcher.cpp index 0d35c0c618..1b9ac355f0 100644 --- a/Libraries/LibDesktop/Launcher.cpp +++ b/Libraries/LibDesktop/Launcher.cpp @@ -54,7 +54,7 @@ private: bool Launcher::open(const URL& url, const String& handler_name) { auto connection = LaunchServerConnection::construct(); - return connection->send_sync<Messages::LaunchServer::OpenUrl>(url.to_string(), handler_name)->response(); + return connection->send_sync<Messages::LaunchServer::OpenURL>(url, handler_name)->response(); } Vector<String> Launcher::get_handlers_for_url(const URL& url) diff --git a/Libraries/LibIPC/Decoder.cpp b/Libraries/LibIPC/Decoder.cpp index 372fd8dd1c..83c2af0fbb 100644 --- a/Libraries/LibIPC/Decoder.cpp +++ b/Libraries/LibIPC/Decoder.cpp @@ -25,6 +25,7 @@ */ #include <AK/BufferStream.h> +#include <AK/URL.h> #include <LibIPC/Decoder.h> #include <LibIPC/Dictionary.h> @@ -113,6 +114,15 @@ bool Decoder::decode(String& value) return !m_stream.handle_read_failure(); } +bool Decoder::decode(URL& value) +{ + String string; + if (!decode(string)) + return false; + value = URL(string); + return true; +} + bool Decoder::decode(Dictionary& dictionary) { u64 size = 0; @@ -136,13 +146,4 @@ bool Decoder::decode(Dictionary& dictionary) return true; } -void dongle() { - ByteBuffer buffer; - BufferStream stream(buffer); - Decoder d(stream); - Vector<String> x; - d.decode(x); -} - - } diff --git a/Libraries/LibIPC/Decoder.h b/Libraries/LibIPC/Decoder.h index 340a86701f..5720d7eafa 100644 --- a/Libraries/LibIPC/Decoder.h +++ b/Libraries/LibIPC/Decoder.h @@ -60,6 +60,7 @@ public: bool decode(i64&); bool decode(float&); bool decode(String&); + bool decode(URL&); bool decode(Dictionary&); template<typename T> diff --git a/Libraries/LibIPC/Encoder.cpp b/Libraries/LibIPC/Encoder.cpp index 36f302dbeb..af93c9918e 100644 --- a/Libraries/LibIPC/Encoder.cpp +++ b/Libraries/LibIPC/Encoder.cpp @@ -25,6 +25,7 @@ */ #include <AK/String.h> +#include <AK/URL.h> #include <LibIPC/Dictionary.h> #include <LibIPC/Encoder.h> @@ -140,6 +141,11 @@ Encoder& Encoder::operator<<(const String& value) return *this << value.view(); } +Encoder& Encoder::operator<<(const URL& value) +{ + return *this << value.to_string(); +} + Encoder& Encoder::operator<<(const Dictionary& dictionary) { *this << (u64)dictionary.size(); diff --git a/Libraries/LibIPC/Encoder.h b/Libraries/LibIPC/Encoder.h index 90b1372ce0..ead9d5541a 100644 --- a/Libraries/LibIPC/Encoder.h +++ b/Libraries/LibIPC/Encoder.h @@ -58,6 +58,7 @@ public: Encoder& operator<<(const char*); Encoder& operator<<(const StringView&); Encoder& operator<<(const String&); + Encoder& operator<<(const URL&); Encoder& operator<<(const Dictionary&); template<typename T> diff --git a/Services/LaunchServer/ClientConnection.cpp b/Services/LaunchServer/ClientConnection.cpp index e69d6fce86..168d6a6727 100644 --- a/Services/LaunchServer/ClientConnection.cpp +++ b/Services/LaunchServer/ClientConnection.cpp @@ -53,11 +53,11 @@ OwnPtr<Messages::LaunchServer::GreetResponse> ClientConnection::handle(const Mes return make<Messages::LaunchServer::GreetResponse>(client_id()); } -OwnPtr<Messages::LaunchServer::OpenUrlResponse> ClientConnection::handle(const Messages::LaunchServer::OpenUrl& request) +OwnPtr<Messages::LaunchServer::OpenURLResponse> ClientConnection::handle(const Messages::LaunchServer::OpenURL& request) { URL url(request.url()); auto result = Launcher::the().open_url(url, request.handler_name()); - return make<Messages::LaunchServer::OpenUrlResponse>(result); + return make<Messages::LaunchServer::OpenURLResponse>(result); } OwnPtr<Messages::LaunchServer::GetHandlersForURLResponse> ClientConnection::handle(const Messages::LaunchServer::GetHandlersForURL& request) diff --git a/Services/LaunchServer/ClientConnection.h b/Services/LaunchServer/ClientConnection.h index 29be882da9..0d1a819f78 100644 --- a/Services/LaunchServer/ClientConnection.h +++ b/Services/LaunchServer/ClientConnection.h @@ -43,7 +43,7 @@ private: explicit ClientConnection(Core::LocalSocket&, int client_id); virtual OwnPtr<Messages::LaunchServer::GreetResponse> handle(const Messages::LaunchServer::Greet&) override; - virtual OwnPtr<Messages::LaunchServer::OpenUrlResponse> handle(const Messages::LaunchServer::OpenUrl&) override; + virtual OwnPtr<Messages::LaunchServer::OpenURLResponse> handle(const Messages::LaunchServer::OpenURL&) override; virtual OwnPtr<Messages::LaunchServer::GetHandlersForURLResponse> handle(const Messages::LaunchServer::GetHandlersForURL&) override; }; } diff --git a/Services/LaunchServer/LaunchServer.ipc b/Services/LaunchServer/LaunchServer.ipc index a4d31a00ed..feeb87015d 100644 --- a/Services/LaunchServer/LaunchServer.ipc +++ b/Services/LaunchServer/LaunchServer.ipc @@ -1,6 +1,6 @@ endpoint LaunchServer = 101 { Greet() => (i32 client_id) - OpenUrl(String url, String handler_name) => (bool response) - GetHandlersForURL(String url) => (Vector<String> handlers) + OpenURL(URL url, String handler_name) => (bool response) + GetHandlersForURL(URL url) => (Vector<String> handlers) } diff --git a/Services/ProtocolServer/ProtocolServer.ipc b/Services/ProtocolServer/ProtocolServer.ipc index c25fc54ca9..80097ebff4 100644 --- a/Services/ProtocolServer/ProtocolServer.ipc +++ b/Services/ProtocolServer/ProtocolServer.ipc @@ -10,6 +10,6 @@ endpoint ProtocolServer = 9 IsSupportedProtocol(String protocol) => (bool supported) // Download API - StartDownload(String url, IPC::Dictionary request_headers) => (i32 download_id) + StartDownload(URL url, IPC::Dictionary request_headers) => (i32 download_id) StopDownload(i32 download_id) => (bool success) } |