summaryrefslogtreecommitdiffstats
path: root/src/portal_service.cpp
blob: 0344830b17b745fdf62584625057a996825e505c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*******************************************************************************
  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,
  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>

// TDE
#include <tdemessagebox.h>
#include <kdebug.h>

// Portal
#include "account_portal.h"
#include "email_portal.h"
#include "file_chooser_portal.h"
#include "portal_service.h"


static const char *dbusObjectPath = "/org/freedesktop/portal/desktop";
static const char *dbusInterfaceRoot = "org.freedesktop.impl.portal";

DesktopNodeService::DesktopNodeService(TQT_DBusConnection &connection)
: org::freedesktop::portal::desktopNode(),
  m_connection(connection)
{
    m_interfaces.insert("org.freedesktop.DBus.Introspectable", this);

    REGISTER_PORTAL(TDEAccountPortal)
    REGISTER_PORTAL(TDEEmailPortal)
    REGISTER_PORTAL(TDEFileChooserPortal)

    registerObject(connection, dbusObjectPath);
}

DesktopNodeService::~DesktopNodeService()
{
    DESTROY_PORTAL(TDEAccountPortal)
    DESTROY_PORTAL(TDEEmailPortal)
    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()
{
}

TQT_DBusObjectBase* PortalNodeService::createInterface(const TQString& iface)
{
    return (TQT_DBusObjectBase*) m_interfaces[iface];
}

// ----------------------------------------------------------------------------------------

FreeDesktopNodeService::FreeDesktopNodeService(TQT_DBusConnection &connection)
: DBusBaseNode(), m_connection(connection)
{
    addChildNode("portal");
    registerObject(m_connection, "/org/freedesktop");
}

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()
{
}

TQT_DBusObjectBase* RootNodeService::createInterface(const TQString& iface)
{
    return (TQT_DBusObjectBase*) m_interfaces[iface];
}

// kate: replace-tabs true; tab-width 4; indent-width 4;