summaryrefslogtreecommitdiffstats
path: root/src/PortalService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/PortalService.cpp')
-rw-r--r--src/PortalService.cpp652
1 files changed, 652 insertions, 0 deletions
diff --git a/src/PortalService.cpp b/src/PortalService.cpp
new file mode 100644
index 0000000..47acb67
--- /dev/null
+++ b/src/PortalService.cpp
@@ -0,0 +1,652 @@
+/*******************************************************************************
+ XDG desktop portal implementation for TDE
+ Copyright © 2024 Mavridis Philippe <mavridisf@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,
+ or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Improvements and feedback are welcome!
+*******************************************************************************/
+
+// TQt
+#include <tqdbusmessage.h>
+#include <tqdbusvariant.h>
+
+// TDE
+#include <tdemessagebox.h>
+#include <kdebug.h>
+
+// Portal
+#include "PortalService.h"
+
+#define INTROSPECTABLE_DBUS_SRVC "org.freedesktop.DBus.Introspectable"
+#define PORTAL_DBUS_SRVC "org.freedesktop.impl.portal.desktop.tde"
+#define PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop"
+
+#define FREEDESKTOP_DBUS_PROPERTIES_SRVC "org.freedesktop.DBus.Properties"
+
+#define PORTAL_DBUS_APPCHOOSER_SRVC "org.freedesktop.impl.portal.AppChooser"
+#define PORTAL_DBUS_DYNAMICLAUNCHER_SRVC "org.freedesktop.impl.portal.DynamicLauncher"
+#define PORTAL_DBUS_FILECHOOSER_SRVC "org.freedesktop.impl.portal.FileChooser"
+#define PORTAL_DBUS_ACCOUNT_SRVC "org.freedesktop.impl.portal.Account"
+#define PORTAL_DBUS_ACCESS_SRVC "org.freedesktop.impl.portal.Access"
+#define PORTAL_DBUS_LOCKDOWN_SRVC "org.freedesktop.impl.portal.Lockdown"
+#define PORTAL_DBUS_EMAIL_SRVC "org.freedesktop.impl.portal.Email"
+#define PORTAL_DBUS_PRINT_SRVC "org.freedesktop.impl.portal.Print"
+#define PORTAL_DBUS_SESTTINGS_SRVC "org.freedesktop.impl.portal.Settings"
+#define PORTAL_DBUS_INHIBIT_SRVC "org.freedesktop.impl.portal.Inhibit"
+#define PORTAL_DBUS_NOTIFICATION_SRVC "org.freedesktop.impl.portal.Notification"
+
+#define PORTAL_DBUS_SESSION_SRVC "org.freedesktop.impl.portal.Session"
+#define PORTAL_DBUS_SESSION_PATH "/org/freedesktop/portal/desktop/session"
+
+PropertiesService::PropertiesService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+
+}
+
+PropertiesService::~PropertiesService(){
+}
+
+void PropertiesService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+bool PropertiesService::Get(const TQString& interface, const TQString& name, TQT_DBusVariant& value, TQT_DBusError& error) {
+ // do something
+ // get interface
+ // get param name from interface
+// value.value = TQT_DBusData::fromUInt64(131719);
+// value.signature = value.value.buildDBusSignature();
+ return true;
+}
+
+bool PropertiesService::Set(const TQString& interface, const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool PropertiesService::GetAll(const TQString& interface, TQMap< TQString, TQT_DBusVariant >& properties, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool PropertiesService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString PropertiesService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+
+/*
+ * Services
+ */
+
+// // // // // // AccessService
+
+AccessService::AccessService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+AccessService::~AccessService(){
+}
+
+bool AccessService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString AccessService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool AccessService::AccessDialog(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQString& title, const TQString& subtitle,
+ const TQString& body, const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void AccessService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // AccountService
+
+AccountService::AccountService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+AccountService::~AccountService(){
+}
+
+bool AccountService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString AccountService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool AccountService::GetUserInformation(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& window, const TQMap<TQString, TQT_DBusVariant>& options,
+ TQ_UINT32& response, TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void AccountService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // AppChooserService
+
+AppChooserService::AppChooserService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+AppChooserService::~AppChooserService(){
+}
+
+bool AppChooserService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString AppChooserService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool AppChooserService::ChooseApplication(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQStringList& choices,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool AppChooserService::UpdateChoices(const TQT_DBusObjectPath& handle,
+ const TQStringList& choices, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void AppChooserService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // DynamicLauncherService
+
+DynamicLauncherService::DynamicLauncherService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+DynamicLauncherService::~DynamicLauncherService(){
+}
+
+bool DynamicLauncherService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString DynamicLauncherService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool DynamicLauncherService::PrepareInstall(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQString& name, const TQT_DBusVariant& icon_v,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool DynamicLauncherService::RequestInstallToken(const TQString& app_id,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void DynamicLauncherService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // EmailService
+
+EmailService::EmailService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+EmailService::~EmailService(){
+}
+
+bool EmailService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString EmailService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool EmailService::ComposeEmail(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void EmailService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // FileChooserService
+
+FileChooserService::FileChooserService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+FileChooserService::~FileChooserService(){
+}
+
+bool FileChooserService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString FileChooserService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool FileChooserService::OpenFile(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQString& title,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool FileChooserService::SaveFile(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQString& title,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool FileChooserService::SaveFiles(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQString& title,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void FileChooserService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // InhibitService
+
+InhibitService::InhibitService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+InhibitService::~InhibitService(){
+}
+
+bool InhibitService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString InhibitService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool InhibitService::Inhibit(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& window, TQ_UINT32 flags,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool InhibitService::CreateMonitor(const TQT_DBusObjectPath& handle,
+ const TQT_DBusObjectPath& session_handle, const TQString& app_id,
+ const TQString& window, TQ_UINT32& response, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool InhibitService::QueryEndResponse(const TQT_DBusObjectPath& session_handle, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void InhibitService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // LockdownService
+
+LockdownService::LockdownService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+LockdownService::~LockdownService(){
+}
+
+bool LockdownService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString LockdownService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+void LockdownService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+
+// // // // // // NotificationService
+
+NotificationService::NotificationService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+NotificationService::~NotificationService(){
+}
+
+bool NotificationService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString NotificationService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool NotificationService::AddNotification(const TQString& app_id, const TQString& id,
+ const TQMap<TQString, TQT_DBusVariant>& notification, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool NotificationService::RemoveNotification(const TQString& app_id,
+ const TQString& id, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void NotificationService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // PrintService
+
+PrintService::PrintService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+PrintService::~PrintService(){
+}
+
+bool PrintService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString PrintService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool PrintService::Print(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQString& title, const TQT_DBusUnixFd& fd,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool PrintService::PreparePrint(const TQT_DBusObjectPath& handle, const TQString& app_id,
+ const TQString& parent_window, const TQString& title,
+ const TQMap<TQString, TQT_DBusVariant>& settings,
+ const TQMap<TQString, TQT_DBusVariant>& page_setup,
+ const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response,
+ TQMap<TQString, TQT_DBusVariant>& results, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void PrintService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // SettingsService
+
+SettingsService::SettingsService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+SettingsService::~SettingsService(){
+}
+
+bool SettingsService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString SettingsService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool SettingsService::ReadAll(const TQStringList& namespaces,
+ TQT_DBusDataMap<TQString>& value, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+bool SettingsService::Read(const TQString& _namespace,
+ const TQString& key, TQT_DBusVariant& value, TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void SettingsService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+
+// // // // // // SessionService
+
+SessionService::SessionService(TQT_DBusConnection &conn)
+ : m_connection(&conn)
+{
+}
+
+SessionService::~SessionService(){
+}
+
+bool SessionService::handleSignalSend(const TQT_DBusMessage& reply) {
+ // do something
+ return true;
+}
+
+TQString SessionService::objectPath() const {
+ // do something
+ return TQString();
+}
+
+bool SessionService::Close(TQT_DBusError& error) {
+ // do something
+ return true;
+}
+
+void SessionService::handleMethodReply(const TQT_DBusMessage& reply) {
+ m_connection->send(reply);
+}
+
+// // // // // // RootNodeService
+
+RootNodeService::RootNodeService(TQT_DBusConnection &connection )
+: DBusBaseNode(), mConnection(connection)
+{
+ addChildNode(TQString("org"));
+ registerObject(mConnection,TQString("/"));
+}
+
+RootNodeService::~RootNodeService(){
+}
+
+TQT_DBusObjectBase* RootNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) mInterfaces[interfaceName];
+}
+
+// // // // // // OrgNodeService
+
+OrgNodeService::OrgNodeService(TQT_DBusConnection &connection )
+: DBusBaseNode(), mConnection(connection)
+{
+ addChildNode(TQString("freedesktop"));
+ registerObject(mConnection,TQString("/org"));
+}
+
+OrgNodeService::~OrgNodeService(){
+}
+
+TQT_DBusObjectBase* OrgNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) mInterfaces[interfaceName];
+}
+
+// // // // // // FreeDesktopNodeService
+
+FreeDesktopNodeService::FreeDesktopNodeService(TQT_DBusConnection &connection )
+: DBusBaseNode(), mConnection(connection)
+{
+ addChildNode(TQString("portal"));
+ registerObject(mConnection,TQString("/org/freedesktop"));
+}
+
+FreeDesktopNodeService::~FreeDesktopNodeService(){
+}
+
+TQT_DBusObjectBase* FreeDesktopNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) mInterfaces[interfaceName];
+}
+
+// // // // // // PortalNodeService
+
+PortalNodeService::PortalNodeService(TQT_DBusConnection &conn)
+: DBusBaseNode(), mConnection(conn)
+{
+ addChildNode(TQString("desktop"));
+ registerObject(mConnection,TQString("/org/freedesktop/portal"));
+}
+
+PortalNodeService::~PortalNodeService(){
+}
+
+TQT_DBusObjectBase* PortalNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) mInterfaces[interfaceName];
+}
+
+// // // // // // DesktopNodeService
+
+DesktopNodeService::DesktopNodeService(TQT_DBusConnection &conn)
+: org::freedesktop::portal::desktopNode(),
+ mConnection(conn)
+{
+ addChildNode(TQString("session"));
+
+ mInterfaces.insert(INTROSPECTABLE_DBUS_SRVC, this);
+ mInterfaces.insert(FREEDESKTOP_DBUS_PROPERTIES_SRVC, new PropertiesService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_APPCHOOSER_SRVC, new AppChooserService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_DYNAMICLAUNCHER_SRVC, new DynamicLauncherService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_FILECHOOSER_SRVC, new FileChooserService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_ACCOUNT_SRVC, new AccountService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_ACCESS_SRVC, new AccessService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_LOCKDOWN_SRVC, new LockdownService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_EMAIL_SRVC, new EmailService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_PRINT_SRVC, new PrintService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_SESTTINGS_SRVC, new SettingsService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_INHIBIT_SRVC, new InhibitService(mConnection));
+ mInterfaces.insert(PORTAL_DBUS_NOTIFICATION_SRVC, new NotificationService(mConnection));
+ // TODO implement Session handling
+// mInterfaces.insert(PORTAL_DBUS_SESSION_SRVC, new SessionService(mConnection));
+ registerObject(mConnection,TQString(PORTAL_DBUS_PATH));
+}
+
+DesktopNodeService::~DesktopNodeService(){
+}
+
+TQT_DBusObjectBase* DesktopNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) mInterfaces[interfaceName];
+}
+
+// // // // // // SessionNodeService
+
+SessionNodeService::SessionNodeService(TQT_DBusConnection &conn)
+: org::freedesktop::portal::desktop::sessionNode(),
+ mConnection(conn)
+{
+ mInterfaces.insert(INTROSPECTABLE_DBUS_SRVC, new SessionService(mConnection));
+ registerObject(mConnection,TQString(PORTAL_DBUS_SESSION_PATH));
+}
+
+SessionNodeService::~SessionNodeService(){
+}
+
+TQT_DBusObjectBase* SessionNodeService::createInterface(const TQString& interfaceName)
+{
+ return (TQT_DBusObjectBase*) mInterfaces[interfaceName];
+}
+
+// kate: replace-tabs true; tab-width 4; indent-width 4;