summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/IRCClient/IRCClient.cpp2
-rw-r--r--Applications/IRCClient/IRCClient.h4
-rw-r--r--Applications/ProcessManager/ProcessModel.cpp6
-rw-r--r--Applications/TextEditor/main.cpp6
-rw-r--r--LibCore/CFile.cpp (renamed from LibGUI/GFile.cpp)20
-rw-r--r--LibCore/CFile.h21
-rw-r--r--LibCore/CIODevice.cpp (renamed from LibGUI/GIODevice.cpp)32
-rw-r--r--LibCore/CIODevice.h (renamed from LibGUI/GIODevice.h)10
-rw-r--r--LibCore/CSocket.cpp (renamed from LibGUI/GSocket.cpp)24
-rw-r--r--LibCore/CSocket.h (renamed from LibGUI/GSocket.h)24
-rw-r--r--LibCore/CSocketAddress.h (renamed from LibGUI/GSocketAddress.h)8
-rw-r--r--LibCore/CTCPSocket.cpp (renamed from LibGUI/GTCPSocket.cpp)10
-rw-r--r--LibCore/CTCPSocket.h10
-rw-r--r--LibCore/Makefile4
-rw-r--r--LibGUI/GFile.h21
-rw-r--r--LibGUI/GHttpJob.cpp4
-rw-r--r--LibGUI/GHttpJob.h4
-rw-r--r--LibGUI/GTCPSocket.h10
-rw-r--r--LibGUI/Makefile4
19 files changed, 112 insertions, 112 deletions
diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp
index a6310789b6..0a9cb11790 100644
--- a/Applications/IRCClient/IRCClient.cpp
+++ b/Applications/IRCClient/IRCClient.cpp
@@ -32,7 +32,7 @@ IRCClient::IRCClient()
, m_client_window_list_model(IRCWindowListModel::create(*this))
, m_log(IRCLogBuffer::create())
{
- m_socket = new GTCPSocket(this);
+ m_socket = new CTCPSocket(this);
}
IRCClient::~IRCClient()
diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h
index a493fd2975..2ee82d2bb2 100644
--- a/Applications/IRCClient/IRCClient.h
+++ b/Applications/IRCClient/IRCClient.h
@@ -4,7 +4,7 @@
#include <AK/HashMap.h>
#include <AK/CircularQueue.h>
#include <AK/Function.h>
-#include <LibGUI/GTCPSocket.h>
+#include <LibCore/CTCPSocket.h>
#include "IRCLogBuffer.h"
#include "IRCWindow.h"
@@ -114,7 +114,7 @@ private:
String m_hostname;
int m_port { 6667 };
- GTCPSocket* m_socket { nullptr };
+ CTCPSocket* m_socket { nullptr };
String m_nickname;
Vector<char> m_line_buffer;
diff --git a/Applications/ProcessManager/ProcessModel.cpp b/Applications/ProcessManager/ProcessModel.cpp
index 0a0204d05f..c83bb2c2f2 100644
--- a/Applications/ProcessManager/ProcessModel.cpp
+++ b/Applications/ProcessManager/ProcessModel.cpp
@@ -1,5 +1,5 @@
#include "ProcessModel.h"
-#include <LibGUI/GFile.h>
+#include <LibCore/CFile.h>
#include <fcntl.h>
#include <stdio.h>
#include <pwd.h>
@@ -125,8 +125,8 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
void ProcessModel::update()
{
- GFile file("/proc/all");
- if (!file.open(GIODevice::ReadOnly)) {
+ CFile file("/proc/all");
+ if (!file.open(CIODevice::ReadOnly)) {
fprintf(stderr, "ProcessManager: Failed to open /proc/all: %s\n", file.error_string());
exit(1);
return;
diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp
index 42dc167551..d3aa6d38ec 100644
--- a/Applications/TextEditor/main.cpp
+++ b/Applications/TextEditor/main.cpp
@@ -8,7 +8,7 @@
#include <LibGUI/GTextEditor.h>
#include <LibGUI/GAction.h>
#include <LibGUI/GFontDatabase.h>
-#include <LibGUI/GFile.h>
+#include <LibCore/CFile.h>
#include <AK/StringBuilder.h>
#include <unistd.h>
#include <stdio.h>
@@ -35,9 +35,9 @@ int main(int argc, char** argv)
String path = "/tmp/TextEditor.save.txt";
if (argc >= 2) {
path = argv[1];
- GFile file(path);
+ CFile file(path);
- if (!file.open(GIODevice::ReadOnly)) {
+ if (!file.open(CIODevice::ReadOnly)) {
fprintf(stderr, "Opening %s: %s\n", path.characters(), file.error_string());
return 1;
}
diff --git a/LibGUI/GFile.cpp b/LibCore/CFile.cpp
index e0ff42e0bb..fa6c0d6a8d 100644
--- a/LibGUI/GFile.cpp
+++ b/LibCore/CFile.cpp
@@ -1,34 +1,34 @@
-#include <LibGUI/GFile.h>
+#include <LibCore/CFile.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
-GFile::GFile(const String& filename)
+CFile::CFile(const String& filename)
: m_filename(filename)
{
}
-GFile::~GFile()
+CFile::~CFile()
{
if (mode() != NotOpen)
close();
}
-bool GFile::open(GIODevice::OpenMode mode)
+bool CFile::open(CIODevice::OpenMode mode)
{
int flags = 0;
- if ((mode & GIODevice::ReadWrite) == GIODevice::ReadWrite) {
+ if ((mode & CIODevice::ReadWrite) == CIODevice::ReadWrite) {
flags |= O_RDWR | O_CREAT;
- } else if (mode & GIODevice::ReadOnly) {
+ } else if (mode & CIODevice::ReadOnly) {
flags |= O_RDONLY;
- } else if (mode & GIODevice::WriteOnly) {
+ } else if (mode & CIODevice::WriteOnly) {
flags |= O_WRONLY | O_CREAT;
}
- if (mode & GIODevice::Append)
+ if (mode & CIODevice::Append)
flags |= O_APPEND;
- if (mode & GIODevice::Truncate)
+ if (mode & CIODevice::Truncate)
flags |= O_TRUNC;
- if (mode & GIODevice::MustBeNew)
+ if (mode & CIODevice::MustBeNew)
flags |= O_EXCL;
int fd = ::open(m_filename.characters(), flags, 0666);
if (fd < 0) {
diff --git a/LibCore/CFile.h b/LibCore/CFile.h
new file mode 100644
index 0000000000..bbccf790f6
--- /dev/null
+++ b/LibCore/CFile.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <LibCore/CIODevice.h>
+#include <AK/AKString.h>
+
+class CFile final : public CIODevice {
+public:
+ CFile() { }
+ explicit CFile(const String&);
+ virtual ~CFile() override;
+
+ String filename() const { return m_filename; }
+ void set_filename(const String& filename) { m_filename = filename; }
+
+ virtual bool open(CIODevice::OpenMode) override;
+
+ virtual const char* class_name() const override { return "CFile"; }
+
+private:
+ String m_filename;
+};
diff --git a/LibGUI/GIODevice.cpp b/LibCore/CIODevice.cpp
index 5766de65b9..80ac9ef18e 100644
--- a/LibGUI/GIODevice.cpp
+++ b/LibCore/CIODevice.cpp
@@ -1,23 +1,23 @@
-#include <LibGUI/GIODevice.h>
+#include <LibCore/CIODevice.h>
#include <unistd.h>
#include <sys/select.h>
#include <stdio.h>
-GIODevice::GIODevice(CObject* parent)
+CIODevice::CIODevice(CObject* parent)
: CObject(parent)
{
}
-GIODevice::~GIODevice()
+CIODevice::~CIODevice()
{
}
-const char* GIODevice::error_string() const
+const char* CIODevice::error_string() const
{
return strerror(m_error);
}
-ByteBuffer GIODevice::read(int max_size)
+ByteBuffer CIODevice::read(int max_size)
{
if (m_fd < 0)
return { };
@@ -50,9 +50,9 @@ ByteBuffer GIODevice::read(int max_size)
return buffer;
}
-bool GIODevice::can_read_from_fd() const
+bool CIODevice::can_read_from_fd() const
{
- // FIXME: Can we somehow remove this once GSocket is implemented using non-blocking sockets?
+ // FIXME: Can we somehow remove this once CSocket is implemented using non-blocking sockets?
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(m_fd, &rfds);
@@ -60,13 +60,13 @@ bool GIODevice::can_read_from_fd() const
int rc = select(m_fd + 1, &rfds, nullptr, nullptr, &timeout);
if (rc < 0) {
// NOTE: We don't set m_error here.
- perror("GIODevice::can_read: select");
+ perror("CIODevice::can_read: select");
return false;
}
return FD_ISSET(m_fd, &rfds);
}
-bool GIODevice::can_read_line()
+bool CIODevice::can_read_line()
{
if (m_eof && !m_buffered_data.is_empty())
return true;
@@ -78,12 +78,12 @@ bool GIODevice::can_read_line()
return m_buffered_data.contains_slow('\n');
}
-bool GIODevice::can_read() const
+bool CIODevice::can_read() const
{
return !m_buffered_data.is_empty() || can_read_from_fd();
}
-ByteBuffer GIODevice::read_all()
+ByteBuffer CIODevice::read_all()
{
ByteBuffer buffer;
if (!m_buffered_data.is_empty()) {
@@ -107,7 +107,7 @@ ByteBuffer GIODevice::read_all()
return buffer;
}
-ByteBuffer GIODevice::read_line(int max_size)
+ByteBuffer CIODevice::read_line(int max_size)
{
if (m_fd < 0)
return { };
@@ -117,7 +117,7 @@ ByteBuffer GIODevice::read_line(int max_size)
return { };
if (m_eof) {
if (m_buffered_data.size() > max_size) {
- printf("GIODevice::read_line: At EOF but there's more than max_size(%d) buffered\n", max_size);
+ printf("CIODevice::read_line: At EOF but there's more than max_size(%d) buffered\n", max_size);
return { };
}
auto buffer = ByteBuffer::copy(m_buffered_data.data(), m_buffered_data.size());
@@ -141,7 +141,7 @@ ByteBuffer GIODevice::read_line(int max_size)
return { };
}
-bool GIODevice::populate_read_buffer()
+bool CIODevice::populate_read_buffer()
{
if (m_fd < 0)
return false;
@@ -160,7 +160,7 @@ bool GIODevice::populate_read_buffer()
return true;
}
-bool GIODevice::close()
+bool CIODevice::close()
{
if (fd() < 0 || mode() == NotOpen)
return false;
@@ -170,6 +170,6 @@ bool GIODevice::close()
return false;
}
set_fd(-1);
- set_mode(GIODevice::NotOpen);
+ set_mode(CIODevice::NotOpen);
return true;
}
diff --git a/LibGUI/GIODevice.h b/LibCore/CIODevice.h
index 4b2150ef01..931fcb2ce5 100644
--- a/LibGUI/GIODevice.h
+++ b/LibCore/CIODevice.h
@@ -3,7 +3,7 @@
#include <LibCore/CObject.h>
#include <AK/ByteBuffer.h>
-class GIODevice : public CObject {
+class CIODevice : public CObject {
public:
enum OpenMode {
NotOpen = 0,
@@ -15,7 +15,7 @@ public:
MustBeNew = 16,
};
- virtual ~GIODevice() override;
+ virtual ~CIODevice() override;
int fd() const { return m_fd; }
unsigned mode() const { return m_mode; }
@@ -35,13 +35,13 @@ public:
bool can_read() const;
- virtual bool open(GIODevice::OpenMode) = 0;
+ virtual bool open(CIODevice::OpenMode) = 0;
virtual bool close();
- virtual const char* class_name() const override { return "GIODevice"; }
+ virtual const char* class_name() const override { return "CIODevice"; }
protected:
- explicit GIODevice(CObject* parent = nullptr);
+ explicit CIODevice(CObject* parent = nullptr);
void set_fd(int fd) { m_fd = fd; }
void set_mode(OpenMode mode) { m_mode = mode; }
diff --git a/LibGUI/GSocket.cpp b/LibCore/CSocket.cpp
index 6b088e2dbe..70f90fe88f 100644
--- a/LibGUI/GSocket.cpp
+++ b/LibCore/CSocket.cpp
@@ -1,4 +1,4 @@
-#include <LibGUI/GSocket.h>
+#include <LibCore/CSocket.h>
#include <LibCore/CNotifier.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -8,33 +8,33 @@
#include <netdb.h>
#include <errno.h>
-GSocket::GSocket(Type type, CObject* parent)
- : GIODevice(parent)
+CSocket::CSocket(Type type, CObject* parent)
+ : CIODevice(parent)
, m_type(type)
{
}
-GSocket::~GSocket()
+CSocket::~CSocket()
{
}
-bool GSocket::connect(const String& hostname, int port)
+bool CSocket::connect(const String& hostname, int port)
{
auto* hostent = gethostbyname(hostname.characters());
if (!hostent) {
- dbgprintf("GSocket::connect: Unable to resolve '%s'\n", hostname.characters());
+ dbgprintf("CSocket::connect: Unable to resolve '%s'\n", hostname.characters());
return false;
}
IPv4Address host_address((const byte*)hostent->h_addr_list[0]);
- dbgprintf("GSocket::connect: Resolved '%s' to %s\n", hostname.characters(), host_address.to_string().characters());
+ dbgprintf("CSocket::connect: Resolved '%s' to %s\n", hostname.characters(), host_address.to_string().characters());
return connect(host_address, port);
}
-bool GSocket::connect(const GSocketAddress& address, int port)
+bool CSocket::connect(const CSocketAddress& address, int port)
{
ASSERT(!is_connected());
- ASSERT(address.type() == GSocketAddress::Type::IPv4);
+ ASSERT(address.type() == CSocketAddress::Type::IPv4);
ASSERT(port > 0 && port <= 65535);
struct sockaddr_in addr;
@@ -71,17 +71,17 @@ bool GSocket::connect(const GSocketAddress& address, int port)
return true;
}
-ByteBuffer GSocket::receive(int max_size)
+ByteBuffer CSocket::receive(int max_size)
{
auto buffer = read(max_size);
if (eof()) {
- dbgprintf("GSocket{%p}: Connection appears to have closed in receive().\n", this);
+ dbgprintf("CSocket{%p}: Connection appears to have closed in receive().\n", this);
m_connected = false;
}
return buffer;
}
-bool GSocket::send(const ByteBuffer& data)
+bool CSocket::send(const ByteBuffer& data)
{
int nsent = ::send(fd(), data.pointer(), data.size(), 0);
if (nsent < 0) {
diff --git a/LibGUI/GSocket.h b/LibCore/CSocket.h
index 697845d2d1..b02133f050 100644
--- a/LibGUI/GSocket.h
+++ b/LibCore/CSocket.h
@@ -1,44 +1,44 @@
#pragma once
-#include <LibGUI/GIODevice.h>
-#include <LibGUI/GSocketAddress.h>
+#include <LibCore/CIODevice.h>
+#include <LibCore/CSocketAddress.h>
class CNotifier;
-class GSocket : public GIODevice {
+class CSocket : public CIODevice {
public:
enum class Type { Invalid, TCP, UDP };
- virtual ~GSocket() override;
+ virtual ~CSocket() override;
bool connect(const String& hostname, int port);
- bool connect(const GSocketAddress&, int port);
+ bool connect(const CSocketAddress&, int port);
ByteBuffer receive(int max_size);
bool send(const ByteBuffer&);
bool is_connected() const { return m_connected; }
- GSocketAddress source_address() const { return m_source_address; }
+ CSocketAddress source_address() const { return m_source_address; }
int source_port() const { return m_source_port; }
- GSocketAddress destination_address() const { return m_source_address; }
+ CSocketAddress destination_address() const { return m_source_address; }
int destination_port() const { return m_destination_port; }
Function<void()> on_connected;
- virtual const char* class_name() const override { return "GSocket"; }
+ virtual const char* class_name() const override { return "CSocket"; }
protected:
- GSocket(Type, CObject* parent);
+ CSocket(Type, CObject* parent);
- GSocketAddress m_source_address;
- GSocketAddress m_destination_address;
+ CSocketAddress m_source_address;
+ CSocketAddress m_destination_address;
int m_source_port { -1 };
int m_destination_port { -1 };
bool m_connected { false };
private:
- virtual bool open(GIODevice::OpenMode) override { ASSERT_NOT_REACHED(); }
+ virtual bool open(CIODevice::OpenMode) override { ASSERT_NOT_REACHED(); }
Type m_type { Type::Invalid };
OwnPtr<CNotifier> m_notifier;
};
diff --git a/LibGUI/GSocketAddress.h b/LibCore/CSocketAddress.h
index c333e64a4e..5de064dd95 100644
--- a/LibGUI/GSocketAddress.h
+++ b/LibCore/CSocketAddress.h
@@ -2,12 +2,12 @@
#include <Kernel/Net/IPv4.h>
-class GSocketAddress {
+class CSocketAddress {
public:
enum class Type { Invalid, IPv4, Local };
- GSocketAddress() { }
- GSocketAddress(const IPv4Address& address)
+ CSocketAddress() { }
+ CSocketAddress(const IPv4Address& address)
: m_type(Type::IPv4)
, m_ipv4_address(address)
{
@@ -21,7 +21,7 @@ public:
{
switch (m_type) {
case Type::IPv4: return m_ipv4_address.to_string();
- default: return "[GSocketAddress]";
+ default: return "[CSocketAddress]";
}
}
diff --git a/LibGUI/GTCPSocket.cpp b/LibCore/CTCPSocket.cpp
index 22fa01f84c..5f3702a482 100644
--- a/LibGUI/GTCPSocket.cpp
+++ b/LibCore/CTCPSocket.cpp
@@ -1,19 +1,19 @@
-#include <LibGUI/GTCPSocket.h>
+#include <LibCore/CTCPSocket.h>
#include <sys/socket.h>
-GTCPSocket::GTCPSocket(CObject* parent)
- : GSocket(GSocket::Type::TCP, parent)
+CTCPSocket::CTCPSocket(CObject* parent)
+ : CSocket(CSocket::Type::TCP, parent)
{
int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (fd < 0) {
set_error(fd);
} else {
set_fd(fd);
- set_mode(GIODevice::ReadWrite);
+ set_mode(CIODevice::ReadWrite);
set_error(0);
}
}
-GTCPSocket::~GTCPSocket()
+CTCPSocket::~CTCPSocket()
{
}
diff --git a/LibCore/CTCPSocket.h b/LibCore/CTCPSocket.h
new file mode 100644
index 0000000000..c48331f9ee
--- /dev/null
+++ b/LibCore/CTCPSocket.h
@@ -0,0 +1,10 @@
+#include <LibCore/CSocket.h>
+
+class CTCPSocket final : public CSocket {
+public:
+ explicit CTCPSocket(CObject* parent = nullptr);
+ virtual ~CTCPSocket() override;
+
+private:
+};
+
diff --git a/LibCore/Makefile b/LibCore/Makefile
index 35a08edc3b..4d4409f008 100644
--- a/LibCore/Makefile
+++ b/LibCore/Makefile
@@ -1,4 +1,8 @@
OBJS = \
+ CIODevice.o \
+ CFile.o \
+ CSocket.o \
+ CTCPSocket.o \
CElapsedTimer.o \
CNotifier.o \
CObject.o \
diff --git a/LibGUI/GFile.h b/LibGUI/GFile.h
deleted file mode 100644
index 89aadf0aad..0000000000
--- a/LibGUI/GFile.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-
-#include <LibGUI/GIODevice.h>
-#include <AK/AKString.h>
-
-class GFile final : public GIODevice {
-public:
- GFile() { }
- explicit GFile(const String&);
- virtual ~GFile() override;
-
- String filename() const { return m_filename; }
- void set_filename(const String& filename) { m_filename = filename; }
-
- virtual bool open(GIODevice::OpenMode) override;
-
- virtual const char* class_name() const override { return "GFile"; }
-
-private:
- String m_filename;
-};
diff --git a/LibGUI/GHttpJob.cpp b/LibGUI/GHttpJob.cpp
index 5ca7675460..9a1f848338 100644
--- a/LibGUI/GHttpJob.cpp
+++ b/LibGUI/GHttpJob.cpp
@@ -1,6 +1,6 @@
#include <LibGUI/GHttpJob.h>
#include <LibGUI/GHttpResponse.h>
-#include <LibGUI/GTCPSocket.h>
+#include <LibCore/CTCPSocket.h>
#include <stdio.h>
#include <unistd.h>
@@ -98,7 +98,7 @@ void GHttpJob::on_socket_connected()
void GHttpJob::start()
{
ASSERT(!m_socket);
- m_socket = new GTCPSocket(this);
+ m_socket = new CTCPSocket(this);
m_socket->on_connected = [this] {
printf("Socket on_connected callback\n");
on_socket_connected();
diff --git a/LibGUI/GHttpJob.h b/LibGUI/GHttpJob.h
index adc0d72155..8ba52728d2 100644
--- a/LibGUI/GHttpJob.h
+++ b/LibGUI/GHttpJob.h
@@ -4,7 +4,7 @@
#include <LibGUI/GHttpRequest.h>
#include <AK/HashMap.h>
-class GTCPSocket;
+class CTCPSocket;
class GHttpJob final : public GNetworkJob {
public:
@@ -26,7 +26,7 @@ private:
};
GHttpRequest m_request;
- GTCPSocket* m_socket { nullptr };
+ CTCPSocket* m_socket { nullptr };
State m_state { State::InStatus };
int m_code { -1 };
HashMap<String, String> m_headers;
diff --git a/LibGUI/GTCPSocket.h b/LibGUI/GTCPSocket.h
deleted file mode 100644
index 676e8def35..0000000000
--- a/LibGUI/GTCPSocket.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <LibGUI/GSocket.h>
-
-class GTCPSocket final : public GSocket {
-public:
- explicit GTCPSocket(CObject* parent);
- virtual ~GTCPSocket() override;
-
-private:
-};
-
diff --git a/LibGUI/Makefile b/LibGUI/Makefile
index b687153aa8..6cdf6c8a7a 100644
--- a/LibGUI/Makefile
+++ b/LibGUI/Makefile
@@ -10,8 +10,6 @@ SHAREDGRAPHICS_OBJS = \
LIBGUI_OBJS = \
GPainter.o \
- GIODevice.o \
- GFile.o \
GButton.o \
GCheckBox.o \
GEventLoop.o \
@@ -39,8 +37,6 @@ LIBGUI_OBJS = \
GSortingProxyModel.o \
GStackWidget.o \
GScrollableWidget.o \
- GSocket.o \
- GTCPSocket.o \
GMessageBox.o \
GInputBox.o \
GDialog.o \