1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:07:44 +00:00

LibIPC+Services: Support URL as a native IPC type

This commit is contained in:
Andreas Kling 2020-06-07 22:54:27 +02:00
parent b81b2a85c4
commit 3654710c41
10 changed files with 26 additions and 16 deletions

View file

@ -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)

View file

@ -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);
}
}

View file

@ -60,6 +60,7 @@ public:
bool decode(i64&);
bool decode(float&);
bool decode(String&);
bool decode(URL&);
bool decode(Dictionary&);
template<typename T>

View file

@ -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();

View file

@ -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>