reworked and created the structure for the complete interface implementation

Note: this is only the structure of the interface
Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
feat/improvements
Emanoil Kotsev 5 months ago
parent ae92cf1205
commit fa084fcf02
No known key found for this signature in database
GPG Key ID: F1EEB8CD9FB16A50

@ -6,7 +6,12 @@
# This software is licensed under the terms of the GNU GPL v3 license. #
################################################################################
cmake_minimum_required( VERSION 3.1 )
##### set project version ########################
include( TDEVersion )
cmake_minimum_required( VERSION ${TDE_CMAKE_MINIMUM_VERSION} )
#### general package setup
project( xdg-desktop-portal-tde )

@ -20,4 +20,10 @@ if( WITH_GCC_VISIBILITY )
tde_setup_gcc_visibility( )
endif( WITH_GCC_VISIBILITY )
tde_setup_dbus( dbus-1-tqt )
# check for dbus-1-tqt
pkg_search_module( DBUS_TQT dbus-1-tqt )
if( NOT DBUS_TQT_FOUND )
tde_message_fatal( "dbus-1-tqt is required, but was not found on your system" )
endif( )
#tde_setup_dbus( dbus-1-tqt )

@ -9,26 +9,71 @@
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${DBUS_TQT_INCLUDE_DIRS}
/usr/include/dbus-1.0
/usr/lib/x86_64-linux-gnu/dbus-1.0/include
)
link_directories(
${DBUS_TQT_LIBRARY_DIRS}
)
set(filechooser_HDRS filechooserInterface.h filechooserProxy.h introspectableInterface.h)
set(filechooser_SRCS filechooserInterface.cpp filechooserProxy.cpp introspectableInterface.cpp)
set( INTROSPECTIONFILE_PORTAL ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.impl.portal.xml )
set( INTROSPECTIONFILE_SESSION ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.impl.portal.Session.xml )
set( DBUSXML2QT3_EXECUTABLE dbusxml2qt3 )
set(xdgportal_HDRS accessInterface.h accessProxy.h accountInterface.h accountProxy.h appchooserInterface.h appchooserProxy.h desktopNode.h dynamiclauncherInterface.h dynamiclauncherProxy.h emailInterface.h emailProxy.h filechooserInterface.h filechooserProxy.h inhibitInterface.h inhibitProxy.h lockdownInterface.h lockdownProxy.h notificationInterface.h notificationProxy.h printInterface.h printProxy.h settingsInterface.h settingsProxy.h propertiesInterface.h)
set(xdgportal_SRCS accessInterface.cpp accessProxy.cpp accountInterface.cpp accountProxy.cpp appchooserInterface.cpp appchooserProxy.cpp desktopNode.cpp dynamiclauncherInterface.cpp dynamiclauncherProxy.cpp emailInterface.cpp emailProxy.cpp filechooserInterface.cpp filechooserProxy.cpp inhibitInterface.cpp inhibitProxy.cpp lockdownInterface.cpp lockdownProxy.cpp notificationInterface.cpp notificationProxy.cpp printInterface.cpp printProxy.cpp settingsInterface.cpp settingsProxy.cpp propertiesInterface.cpp)
set(session_HDRS dbusbaseNode.h introspectableInterface.h sessionInterface.h sessionNode.h sessionProxy.h)
set(session_SRCS dbusbaseNode.cpp introspectableInterface.cpp sessionInterface.cpp sessionNode.cpp sessionProxy.cpp)
add_custom_command(
OUTPUT ${filechooser_HDRS} ${filechooser_SRCS}
COMMAND ${DBUSXML2QT3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/filechooser.xml
DEPENDS filechooser.xml
OUTPUT ${xdgportal_HDRS} ${xdgportal_SRCS} ${session_HDRS} ${session_SRCS}
COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONFILE_PORTAL}
COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONFILE_SESSION}
DEPENDS ${INTROSPECTIONFILE_PORTAL} ${INTROSPECTIONFILE_SESSION}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
tde_add_library(portalinterfaces STATIC_PIC AUTOMOC
SOURCES ${filechooser_SRCS}
LINK ${DBUS_TQT_LIBRARIES}
)
function( make_moc fileinput )
add_custom_command( OUTPUT ${fileinput}.moc
COMMAND ${TMOC_EXECUTABLE} ${fileinput}.h -o ${fileinput}.moc
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set_property( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.cpp APPEND
PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.moc )
endfunction( )
make_moc ( accessProxy )
make_moc ( accountProxy )
make_moc ( appchooserProxy )
make_moc ( dynamiclauncherProxy )
make_moc ( emailProxy )
make_moc ( filechooserProxy )
make_moc ( inhibitProxy )
make_moc ( lockdownProxy )
make_moc ( notificationProxy )
make_moc ( printProxy )
make_moc ( sessionProxy )
make_moc ( settingsProxy )
make_moc ( propertiesProxy )
#tde_add_library( portalinterfaces STATIC_PIC AUTOMOC
# SOURCES
# LINK ${DBUS_TQT_LIBRARIES} tdecore-shared
#)
##### tdexdgdesktopportal (shared) ###########################
tde_add_library( tdexdgdesktopportal SHARED AUTOMOC
SOURCES ${xdgportal_SRCS} ${session_SRCS}
VERSION ${LIBRARY_VERSION}
LINK ${DBUS_TQT_LIBRARIES} tdecore-shared
DESTINATION ${LIB_INSTALL_DIR}
)
##### other data
configure_file(org.freedesktop.impl.portal.desktop.tde.service.cmake
org.freedesktop.impl.portal.desktop.tde.service @ONLY)
@ -39,7 +84,23 @@ configure_file(xdg-desktop-portal-tde.desktop.cmake
install(FILES tde.portal DESTINATION ${XDG_PREFIX}/share/xdg-desktop-portal/portals)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.impl.portal.desktop.tde.service
DESTINATION ${DBUS_SESSION_DIRECTORY})
DESTINATION ${SHARE_INSTALL_PREFIX}/dbus-1/services)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xdg-desktop-portal-tde.desktop
DESTINATION ${SHARE_INSTALL_PREFIX}/applications)
#tde_create_translated_desktop(
# SOURCE xdg-desktop-portal-tde.desktop
# DESTINATION ${AUTOSTART_INSTALL_DIR}
#)
##### install headers ###################################
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DESTINATION ${INCLUDE_INSTALL_DIR}/tdexdgdesktopportal
USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN PATTERN "*.h"
PATTERN "CMakeFiles" EXCLUDE
)

@ -1,32 +0,0 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/">
<interface name="org.freedesktop.impl.portal.FileChooser">
<method name="OpenFile">
<arg name="handle" type="o" direction="in" />
<arg name="app_id" type="s" direction="in" />
<arg name="parent_window" type="s" direction="in" />
<arg name="title" type="s" direction="in" />
<arg name="options" type="a{sv}" direction="in" />
<arg name="response" type="u" direction="out" />
<arg name="results" type="a{sv}" direction="out" />
</method>
<method name="SaveFile">
<arg name="handle" type="o" direction="in" />
<arg name="app_id" type="s" direction="in" />
<arg name="parent_window" type="s" direction="in" />
<arg name="title" type="s" direction="in" />
<arg name="options" type="a{sv}" direction="in" />
<arg name="response" type="u" direction="out" />
<arg name="results" type="a{sv}" direction="out" />
</method>
<method name="SaveFiles">
<arg name="handle" type="o" direction="in" />
<arg name="app_id" type="s" direction="in" />
<arg name="parent_window" type="s" direction="in" />
<arg name="title" type="s" direction="in" />
<arg name="options" type="a{sv}" direction="in" />
<arg name="response" type="u" direction="out" />
<arg name="results" type="a{sv}" direction="out" />
</method>
</interface>
</node>

@ -0,0 +1,13 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/freedesktop/portal/desktop/session">
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" name="xml_data" direction="out" />
</method>
</interface>
<interface name="org.freedesktop.impl.portal.Session">
<method name="Close" />
<signal name="Closed" />
<property type="u" name="version" access="read" />
</interface>
</node>

@ -0,0 +1,220 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/freedesktop/portal/desktop">
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg type="s" name="xml_data" direction="out" />
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg type="s" name="interface_name" direction="in" />
<arg type="s" name="property_name" direction="in" />
<arg type="v" name="value" direction="out" />
</method>
<method name="GetAll">
<arg type="s" name="interface_name" direction="in" />
<arg type="a{sv}" name="properties" direction="out" />
</method>
<method name="Set">
<arg type="s" name="interface_name" direction="in" />
<arg type="s" name="property_name" direction="in" />
<arg type="v" name="value" direction="in" />
</method>
<signal name="PropertiesChanged">
<arg type="s" name="interface_name" />
<arg type="a{sv}" name="changed_properties" />
<arg type="as" name="invalidated_properties" />
</signal>
</interface>
<interface name="org.freedesktop.impl.portal.AppChooser">
<method name="ChooseApplication">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="as" name="choices" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
<method name="UpdateChoices">
<arg type="o" name="handle" direction="in" />
<arg type="as" name="choices" direction="in" />
</method>
</interface>
<interface name="org.freedesktop.impl.portal.DynamicLauncher">
<method name="PrepareInstall">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="s" name="name" direction="in" />
<arg type="v" name="icon_v" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
<method name="RequestInstallToken">
<arg type="s" name="app_id" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
</method>
<property type="u" name="SupportedLauncherTypes"
access="read" />
<property type="u" name="version" access="read" />
</interface>
<interface name="org.freedesktop.impl.portal.FileChooser">
<method name="OpenFile">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="s" name="title" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
<method name="SaveFile">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="s" name="title" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
<method name="SaveFiles">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="s" name="title" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
</interface>
<interface name="org.freedesktop.impl.portal.Account">
<method name="GetUserInformation">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="window" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
</interface>
<interface name="org.freedesktop.impl.portal.Access">
<method name="AccessDialog">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="s" name="title" direction="in" />
<arg type="s" name="subtitle" direction="in" />
<arg type="s" name="body" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
</interface>
<interface name="org.freedesktop.impl.portal.Lockdown">
<property type="b" name="disableprinting" access="readwrite" />
<property type="b" name="disablesavetodisk"
access="readwrite" />
<property type="b" name="disableapplicationhandlers"
access="readwrite" />
<property type="b" name="disablelocation" access="readwrite" />
<property type="b" name="disablecamera" access="readwrite" />
<property type="b" name="disablemicrophone"
access="readwrite" />
<property type="b" name="disablesoundoutput"
access="readwrite" />
</interface>
<interface name="org.freedesktop.impl.portal.Email">
<method name="ComposeEmail">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
</interface>
<interface name="org.freedesktop.impl.portal.Print">
<method name="Print">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="s" name="title" direction="in" />
<arg type="h" name="fd" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
<method name="PreparePrint">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="parent_window" direction="in" />
<arg type="s" name="title" direction="in" />
<arg type="a{sv}" name="settings" direction="in" />
<arg type="a{sv}" name="page_setup" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
<arg type="u" name="response" direction="out" />
<arg type="a{sv}" name="results" direction="out" />
</method>
</interface>
<interface name="org.freedesktop.impl.portal.Settings">
<method name="ReadAll">
<arg type="as" name="namespaces" direction="in" />
<arg type="a{sa{sv}}" name="value" direction="out" />
</method>
<method name="Read">
<arg type="s" name="ns" direction="in" />
<arg type="s" name="key" direction="in" />
<arg type="v" name="value" direction="out" />
</method>
<signal name="SettingChanged">
<arg type="s" name="ns" />
<arg type="s" name="key" />
<arg type="v" name="value" />
</signal>
<property type="u" name="version" access="read" />
</interface>
<interface name="org.freedesktop.impl.portal.Inhibit">
<method name="Inhibit">
<arg type="o" name="handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="window" direction="in" />
<arg type="u" name="flags" direction="in" />
<arg type="a{sv}" name="options" direction="in" />
</method>
<method name="CreateMonitor">
<arg type="o" name="handle" direction="in" />
<arg type="o" name="session_handle" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="window" direction="in" />
<arg type="u" name="response" direction="out" />
</method>
<method name="QueryEndResponse">
<arg type="o" name="session_handle" direction="in" />
</method>
<signal name="StateChanged">
<arg type="o" name="session_handle" />
<arg type="a{sv}" name="state" />
</signal>
</interface>
<interface name="org.freedesktop.impl.portal.Notification">
<method name="AddNotification">
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="id" direction="in" />
<arg type="a{sv}" name="notification" direction="in" />
</method>
<method name="RemoveNotification">
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="id" direction="in" />
</method>
<signal name="ActionInvoked">
<arg type="s" name="app_id" />
<arg type="s" name="id" />
<arg type="s" name="action" />
<arg type="av" name="parameter" />
</signal>
</interface>
<node name="session" />
</node>

@ -24,18 +24,11 @@ link_directories(
tde_add_executable(
xdg-desktop-portal-tde AUTOMOC
SOURCES
main.cpp
portal_service.cpp
file_chooser_portal.cpp
PortalService.cpp PortalServiceDaemon.cpp main.cpp
LINK
tdecore-shared
tdeio-shared
${DBUS_TQT_LIBRARIES}
portalinterfaces-static
tdexdgdesktopportal-shared
DESTINATION ${LIBEXEC_INSTALL_DIR}
)

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

@ -0,0 +1,501 @@
/*******************************************************************************
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!
*******************************************************************************/
#ifndef __PORTAL_SERVICE_H
#define __PORTAL_SERVICE_H
// TQt
#include <tqdbusconnection.h>
#include <tqdbusobject.h>
#include <tqmap.h>
#include <printInterface.h>
#include <settingsInterface.h>
#include <notificationInterface.h>
#include <lockdownInterface.h>
#include <inhibitInterface.h>
#include <filechooserInterface.h>
#include <emailInterface.h>
#include <dynamiclauncherInterface.h>
#include <appchooserInterface.h>
#include <accountInterface.h>
#include <accessInterface.h>
#include <sessionInterface.h>
#include <propertiesInterface.h>
#include <desktopNode.h>
#include <dbusbaseNode.h>
#include <sessionNode.h>
class PropertiesService: public org::freedesktop::DBus::PropertiesInterface
{
public:
PropertiesService(TQT_DBusConnection&);
virtual ~PropertiesService();
protected:
bool handleSignalSend(const TQT_DBusMessage& reply);
TQString objectPath() const;
bool Get(const TQString& interface, const TQString& name, TQT_DBusVariant& value, TQT_DBusError& error);
bool Set(const TQString& interface, const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error);
bool GetAll(const TQString& interface, TQMap<TQString, TQT_DBusVariant>& properties, TQT_DBusError& error);
protected:
// implement sending replies
void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class AccessService: public org::freedesktop::impl::portal::AccessInterface
{
public:
AccessService(TQT_DBusConnection&);
virtual ~AccessService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool 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);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class AccountService: public org::freedesktop::impl::portal::AccountInterface
{
public:
AccountService(TQT_DBusConnection&);
virtual ~AccountService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool 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);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class AppChooserService: public org::freedesktop::impl::portal::AppChooserInterface
{
public:
AppChooserService(TQT_DBusConnection&);
virtual ~AppChooserService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool 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);
virtual bool UpdateChoices(const TQT_DBusObjectPath& handle,
const TQStringList& choices, TQT_DBusError& error);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class DynamicLauncherService: public org::freedesktop::impl::portal::DynamicLauncherInterface
{
public:
DynamicLauncherService(TQT_DBusConnection&);
virtual ~DynamicLauncherService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool 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);
virtual bool RequestInstallToken(const TQString& app_id,
const TQMap<TQString, TQT_DBusVariant>& options, TQ_UINT32& response, TQT_DBusError& error);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class EmailService: public org::freedesktop::impl::portal::EmailInterface
{
public:
EmailService(TQT_DBusConnection&);
virtual ~EmailService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool 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);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class FileChooserService: public org::freedesktop::impl::portal::FileChooserInterface
{
public:
FileChooserService(TQT_DBusConnection&);
virtual ~FileChooserService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool 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);
virtual bool 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);
virtual bool 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);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class InhibitService: public org::freedesktop::impl::portal::InhibitInterface
{
public:
InhibitService(TQT_DBusConnection&);
virtual ~InhibitService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool Inhibit(const TQT_DBusObjectPath& handle, const TQString& app_id,
const TQString& window, TQ_UINT32 flags,
const TQMap<TQString, TQT_DBusVariant>& options, TQT_DBusError& error);
virtual bool CreateMonitor(const TQT_DBusObjectPath& handle,
const TQT_DBusObjectPath& session_handle, const TQString& app_id,
const TQString& window, TQ_UINT32& response, TQT_DBusError& error);
virtual bool QueryEndResponse(const TQT_DBusObjectPath& session_handle, TQT_DBusError& error);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class LockdownService: public org::freedesktop::impl::portal::LockdownInterface
{
public:
LockdownService(TQT_DBusConnection&);
virtual ~LockdownService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
// this requires Properties as there are properties handled here
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class NotificationService: public org::freedesktop::impl::portal::NotificationInterface
{
public:
NotificationService(TQT_DBusConnection&);
virtual ~NotificationService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool AddNotification(const TQString& app_id, const TQString& id,
const TQMap<TQString, TQT_DBusVariant>& notification, TQT_DBusError& error);
virtual bool RemoveNotification(const TQString& app_id, const TQString& id, TQT_DBusError& error);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class PrintService: public org::freedesktop::impl::portal::PrintInterface
{
public:
PrintService(TQT_DBusConnection&);
virtual ~PrintService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
virtual bool 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);
virtual bool 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);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class SettingsService: public org::freedesktop::impl::portal::SettingsInterface
{
public:
SettingsService(TQT_DBusConnection&);
virtual ~SettingsService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool ReadAll(const TQStringList& namespaces, TQT_DBusDataMap<
TQString>& value, TQT_DBusError& error);
virtual bool Read(const TQString& _namespace, const TQString& key, TQT_DBusVariant& value, TQT_DBusError& error);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
class SessionService: public org::freedesktop::impl::portal::SessionInterface
{
public:
SessionService(TQT_DBusConnection&);
virtual ~SessionService();
protected:
// implement methods
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
virtual TQString objectPath() const;
protected:
virtual bool Close(TQT_DBusError& error);
protected:
// implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
};
/**
* RootNodeService
* Service: -
* Path : /
* Children: org
*/
class RootNodeService: public DBusBaseNode
{
public:
RootNodeService(TQT_DBusConnection&);
virtual ~RootNodeService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> mInterfaces;
TQT_DBusConnection mConnection;
};
/**
* OrgNodeService
* Service: -
* Path : /org
* Children: freedesktop
*/
class OrgNodeService: public DBusBaseNode
{
public:
OrgNodeService(TQT_DBusConnection&);
virtual ~OrgNodeService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> mInterfaces;
TQT_DBusConnection mConnection;
};
/**
* FreeDesktopNodeService
* Service: -
* Path : /org/freedesktop
* Children: portal
*/
class FreeDesktopNodeService: public DBusBaseNode
{
public:
FreeDesktopNodeService(TQT_DBusConnection&);
virtual ~FreeDesktopNodeService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> mInterfaces;
TQT_DBusConnection mConnection;
};
/**
* PortalNodeService
* Service: -
* Path : /org/freedesktop/portal
* Children: desktop
*/
class PortalNodeService: public DBusBaseNode
{
public:
PortalNodeService(TQT_DBusConnection&);
virtual ~PortalNodeService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> mInterfaces;
TQT_DBusConnection mConnection;
};
/*
* DesktopNodeService
* Service: org.freedesktop.DBus.Introspectable
* Path : /org/freedesktop/portal/desktop
* Children: session
* Interfaces:
*/
class DesktopNodeService: public org::freedesktop::portal::desktopNode
{
public:
DesktopNodeService(TQT_DBusConnection&);
virtual ~DesktopNodeService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> mInterfaces;
TQT_DBusConnection mConnection;
};
/*
* SessionNodeService
* Service: -
* Path : /org/freedesktop/portal/desktop/session
* Children: -
*/
class SessionNodeService: public org::freedesktop::portal::desktop::sessionNode
{
public:
SessionNodeService(TQT_DBusConnection&);
virtual ~SessionNodeService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> mInterfaces;
TQT_DBusConnection mConnection;
};
#endif // __DESTKOP_PORTAL_H
// kate: replace-tabs true; tab-width 4; indent-width 4;

@ -0,0 +1,143 @@
/*
* PortalServiceDaemon.cpp
*
* Copyright (C) 2021 Emanoil Kotsev <deloptes@gmail.com>
*
*
* This file is part of xdg portal services.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <tqtimer.h>
#include <tqdbusmessage.h>
#include <tqdbuserror.h>
#include "PortalServiceDaemon.h"
// path /org/freedesktop/portal/desktop
#define PORTALSERVICE_DBUS_SRVC "org.freedesktop.impl.portal.desktop.tde"
#define DBUS_CONNECTION_TIMEOUT 4000
#define DBUS_CONNECTION_RETRY 3
PortalServiceDaemon::PortalServiceDaemon()
: KUniqueApplication(),
retryCount(0)
{
// init session connection to dbus
if (!initDBUS()) {
tqDebug("Failed to initialize the connection to DBus");
TQTimer::singleShot(DBUS_CONNECTION_TIMEOUT, this, TQ_SLOT(slotReconnect()));
retryCount++;
}
}
PortalServiceDaemon::~PortalServiceDaemon()
{
// close D-Bus connection
dbusConnectionClose();
}
bool PortalServiceDaemon::initDBUS(){
mConnection = TQT_DBusConnection::addConnection(TQT_DBusConnection::SessionBus, PORTALSERVICE_DBUS_SRVC);
if ( !mConnection.isConnected() ) {
tqDebug("Failed to open connection to system message bus: "
+ mConnection.lastError().message());
return false;
}
mConnection.connect(this, TQ_SLOT(slotDbusSignal(const TQT_DBusMessage&)));
// try to get a specific service name
if (!mConnection.requestName(PORTALSERVICE_DBUS_SRVC, TQT_DBusConnection::NoReplace))
return false;
// make sure we get a reply
mConnection.scheduleDispatch();
return true;
}
void PortalServiceDaemon::dbusConnectionClose() {
if(rootService)
{
delete rootService;
rootService=0;
}
if(orgService)
{
delete orgService;
orgService=0;
}
if(freedesktopService)
{
delete freedesktopService;
freedesktopService=0;
}
if(portalNodeService)
{
delete portalNodeService;
portalNodeService=0;
}
if(desktopNodeService)
{
delete desktopNodeService;
desktopNodeService=0;
}
if(sessionNodeService)
{
delete sessionNodeService;
sessionNodeService=0;
}
if(mConnection.isConnected()) {
mConnection.disconnect(this, TQ_SLOT(slotDbusSignal(const TQT_DBusMessage&)));
mConnection.closeConnection(PORTALSERVICE_DBUS_SRVC);
}
retryCount=0;
}
void PortalServiceDaemon::slotReconnect() {
dbusConnectionClose();
if (!initDBUS()) {
if (DBUS_CONNECTION_RETRY > retryCount) {
tqFatal("Failed to initialize the connection to DBus");
}
TQTimer::singleShot(DBUS_CONNECTION_TIMEOUT, this, TQ_SLOT(slotReconnect()));
retryCount++;
}
}
void PortalServiceDaemon::slotDbusSignal(const TQT_DBusMessage& message) {
TQString serviceName = message[0].toString();
if ( message.interface() == TQString("org.freedesktop.DBus") &&
message.member() == TQString("NameAcquired") &&
serviceName == PORTALSERVICE_DBUS_SRVC )
{
tqDebug("TDEPortalService unique DBus name acquired: " + serviceName);
rootService = new RootNodeService(mConnection);
orgService = new OrgNodeService(mConnection);
freedesktopService = new FreeDesktopNodeService(mConnection);
portalNodeService = new PortalNodeService(mConnection);
desktopNodeService = new DesktopNodeService(mConnection);
//TODO: session needs clarification - perhaps it is registered here, via some app
tqDebug("TDEPortalService service setup done.");
}
}
#include "PortalServiceDaemon.moc"

@ -0,0 +1,75 @@
/*
* PortalServiceDaemon.h
*
* Copyright (C) 2021 Emanoil Kotsev <deloptes@gmail.com>
*
*
* This file is part of kdbusPortalService.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SRC_DAEMON_PORTALSERVICEDAEMON_H_
#define SRC_DAEMON_PORTALSERVICEDAEMON_H_
#include <kuniqueapplication.h>
#include <tqdbusconnection.h>
#include <tqdbusmessage.h>
#include "PortalService.h"
class PortalServiceDaemon : public KUniqueApplication
{
TQ_OBJECT
public:
PortalServiceDaemon();
virtual ~PortalServiceDaemon();
private:
/*!
* This function initialise the connection to the D-Bus daemon.
* \return boolean with the result of the operation
* \retval true if successful initialised D-Bus connection
* \retval false if unsuccessful
*/
bool initDBUS();
//! to close the connection to D-Bus
void dbusConnectionClose();
private:
RootNodeService *rootService;
OrgNodeService *orgService;
FreeDesktopNodeService *freedesktopService;
PortalNodeService *portalNodeService;
DesktopNodeService *desktopNodeService;
SessionNodeService *sessionNodeService;
TQT_DBusConnection mConnection;
int retryCount;
private slots:
/*!
* This function does a reconnect to D-Bus.
* \return void
*/
void slotReconnect();
/*!
* This function is to process D-Bus signals.
* \return void
*/
void slotDbusSignal(const TQT_DBusMessage&);
};
#endif /* SRC_DAEMON_PORTALSERVICEDAEMON_H_ */

@ -29,7 +29,7 @@
#include <tdelocale.h>
// Portal
#include "portal_service.h"
#include "PortalServiceDaemon.h"
static const char description[] = I18N_NOOP("TDE XDG desktop portal");
@ -41,23 +41,22 @@ int main(int argc, char **argv)
description, TDEAboutData::License_LGPL,
I18N_NOOP("Copyright © 2024 Mavridis Philippe"));
TDECmdLineArgs::init(argc, argv, &about);
TDECmdLineArgs::addCmdLineOptions(options);
KUniqueApplication::addCmdLineOptions();
TDECmdLineArgs::init( argc, argv, &about );
// no special cmdline options are needed
// if needed uncomment and implement
// TDECmdLineArgs::addCmdLineOptions( options );
// KUniqueApplication::addCmdLineOptions();
if (!KUniqueApplication::start())
{
tqDebug(i18n("TDEPortalService is already running.\n").local8Bit());
return 0;
}
KUniqueApplication app;
TQT_DBusConnection connection = TQT_DBusConnection::sessionBus();
if (!connection.isConnected())
tqFatal("Failed to connect to session bus!");
if (!connection.requestName("org.freedesktop.impl.portal.desktop.tde"))
tqFatal("Failed to register XDG portal service!");
TDEPortalService portal(connection);
PortalServiceDaemon app;
// not sure if we need session management for this
// if not needed uncomment
// app.disableSessionManagement();
return app.exec();
}

Loading…
Cancel
Save