summaryrefslogtreecommitdiffstats
path: root/src/portal_service.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/portal_service.cpp')
-rw-r--r--src/portal_service.cpp108
1 files changed, 83 insertions, 25 deletions
diff --git a/src/portal_service.cpp b/src/portal_service.cpp
index 86baa63..4e0eae3 100644
--- a/src/portal_service.cpp
+++ b/src/portal_service.cpp
@@ -2,6 +2,9 @@
XDG desktop portal implementation for TDE
Copyright © 2024 Mavridis Philippe <mavridisf@gmail.com>
+ Partially based on code from kdbusnotification
+ Copyright © 2021 Emanoil Kotsev <deloptes@gmail.com>
+
This program or library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the License,
@@ -34,42 +37,97 @@
static const char *dbusObjectPath = "/org/freedesktop/portal/desktop";
static const char *dbusInterfaceRoot = "org.freedesktop.impl.portal";
-TDEPortalService::TDEPortalService(TQT_DBusConnection &connection)
-: m_connection(connection)
+DesktopNodeService::DesktopNodeService(TQT_DBusConnection &connection)
+: org::freedesktop::portal::desktopNode(),
+ m_connection(connection)
+{
+ m_interfaces.insert("org.freedesktop.DBus.Introspectable", this);
+
+ REGISTER_PORTAL(TDEFileChooserPortal)
+
+ registerObject(connection, dbusObjectPath);
+}
+
+DesktopNodeService::~DesktopNodeService()
+{
+ DESTROY_PORTAL(TDEFileChooserPortal)
+}
+
+TQT_DBusObjectBase* DesktopNodeService::createInterface(const TQString& iface)
+{
+ return (TQT_DBusObjectBase*) m_interfaces[iface];
+}
+
+// ----------------------------------------------------------------------------------------
+
+PortalNodeService::PortalNodeService(TQT_DBusConnection &connection)
+: DBusBaseNode(), m_connection(connection)
+{
+ addChildNode("desktop");
+ registerObject(m_connection, "/org/freedesktop/portal");
+}
+
+PortalNodeService::~PortalNodeService()
{
- if (!m_connection.registerObject(dbusObjectPath, this))
- kdFatal() << "Unable to register XDG desktop portal object " << dbusObjectPath << endl;
- else
- kdDebug() << "Registered XDG desktop portal object " << dbusObjectPath << endl;
}
-TDEPortalService::~TDEPortalService()
+TQT_DBusObjectBase* PortalNodeService::createInterface(const TQString& iface)
{
- m_connection.unregisterObject(dbusObjectPath);
+ return (TQT_DBusObjectBase*) m_interfaces[iface];
}
-TQT_DBusObjectBase* TDEPortalService::getPortalInterface(TQCString portal)
+// ----------------------------------------------------------------------------------------
+
+FreeDesktopNodeService::FreeDesktopNodeService(TQT_DBusConnection &connection)
+: DBusBaseNode(), m_connection(connection)
{
- if (portal == "FileChooser")
- return new TDEFileChooserPortal(m_connection);
+ addChildNode("portal");
+ registerObject(m_connection, "/org/freedesktop");
+}
- return nullptr;
+FreeDesktopNodeService::~FreeDesktopNodeService()
+{
+}
+
+TQT_DBusObjectBase* FreeDesktopNodeService::createInterface(const TQString& iface)
+{
+ return (TQT_DBusObjectBase*) m_interfaces[iface];
+}
+
+// ----------------------------------------------------------------------------------------
+
+OrgNodeService::OrgNodeService(TQT_DBusConnection &connection)
+: DBusBaseNode(), m_connection(connection)
+{
+ addChildNode("freedesktop");
+ registerObject(m_connection, "/org");
+}
+
+OrgNodeService::~OrgNodeService()
+{
+}
+
+TQT_DBusObjectBase* OrgNodeService::createInterface(const TQString& iface)
+{
+ return (TQT_DBusObjectBase*) m_interfaces[iface];
+}
+
+// ----------------------------------------------------------------------------------------
+
+RootNodeService::RootNodeService(TQT_DBusConnection &connection)
+: DBusBaseNode(), m_connection(connection)
+{
+ addChildNode("org");
+ registerObject(m_connection, "/");
+}
+
+RootNodeService::~RootNodeService()
+{
}
-bool TDEPortalService::handleMethodCall(const TQT_DBusMessage &message)
+TQT_DBusObjectBase* RootNodeService::createInterface(const TQString& iface)
{
- if (!message.interface().startsWith(dbusInterfaceRoot))
- return false;
-
- TQCString portal = message.interface().mid(TQString(dbusInterfaceRoot).length() + 1).local8Bit();
- TQT_DBusObjectBase *iface = getPortalInterface(portal);
- if (!iface)
- {
- kdWarning() << "Unsupported XDG portal requested: " << portal << endl;
- return false;
- }
-
- return delegateMethodCall(message, iface);
+ return (TQT_DBusObjectBase*) m_interfaces[iface];
}
// kate: replace-tabs true; tab-width 4; indent-width 4; \ No newline at end of file