Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>pull/6/head
parent
c7b0c7b88c
commit
87769ed51d
@ -1,5 +1,19 @@
|
||||
<!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">
|
||||
<!-- Email -->
|
||||
<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>
|
||||
<property name="version" type="u" access="read"/>
|
||||
</interface>
|
||||
|
||||
<!-- FileChooser -->
|
||||
<interface name="org.freedesktop.impl.portal.FileChooser">
|
||||
<method name="OpenFile">
|
||||
<arg name="handle" type="o" direction="in" />
|
@ -0,0 +1,86 @@
|
||||
/*******************************************************************************
|
||||
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!
|
||||
*******************************************************************************/
|
||||
|
||||
// TDE
|
||||
#include <tdeapplication.h>
|
||||
|
||||
// Portal
|
||||
#include "email_portal.h"
|
||||
#include "email_portal.moc"
|
||||
|
||||
TDEEmailPortal::TDEEmailPortal(TQT_DBusConnection &connection)
|
||||
: m_connection(connection)
|
||||
{
|
||||
}
|
||||
|
||||
TDEEmailPortal::~TDEEmailPortal()
|
||||
{
|
||||
}
|
||||
|
||||
void TDEEmailPortal::handleMethodReply(const TQT_DBusMessage &reply)
|
||||
{
|
||||
m_connection.send(reply);
|
||||
}
|
||||
|
||||
bool TDEEmailPortal::handleSignalSend(const TQT_DBusMessage& reply) {
|
||||
handleMethodReply(reply);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TDEEmailPortal::ComposeEmail(const TQT_DBusObjectPath& handle,
|
||||
const TQString& app_id,
|
||||
const TQString& parent_window,
|
||||
const TQT_DBusVariantMap& options,
|
||||
TQ_UINT32& response,
|
||||
TQT_DBusVariantMap &results,
|
||||
TQT_DBusError& error)
|
||||
{
|
||||
// void invokeMailer (const TQString &to, const TQString &cc, const TQString &bcc, const TQString &subject, const TQString &body, const TQString &messageFile=TQString::null, const TQStringList &attachURLs=TQStringList())
|
||||
EmailOpts opts;
|
||||
if (OPTION_VALID("address", "s"))
|
||||
opts.rcpt << options["address"].value.toString();
|
||||
|
||||
if (OPTION_VALID("addresses", "as"))
|
||||
opts.rcpt += options["addresses"].value.toList().toTQStringList();
|
||||
|
||||
if (OPTION_VALID("cc", "as"))
|
||||
opts.cc += options["cc"].value.toList().toTQStringList();
|
||||
|
||||
if (OPTION_VALID("bcc", "as"))
|
||||
opts.bcc += options["bcc"].value.toList().toTQStringList();
|
||||
|
||||
if (OPTION_VALID("subject", "s"))
|
||||
opts.subj = options["subject"].value.toString();
|
||||
|
||||
if (OPTION_VALID("body", "s"))
|
||||
opts.body = options["body"].value.toString();
|
||||
|
||||
if (OPTION_VALID("attachments", "as"))
|
||||
{
|
||||
opts.attach += options["attachments"].value.toList().toTQStringList();
|
||||
}
|
||||
|
||||
kapp->invokeMailer(opts.rcpt.join(";"), opts.cc.join(";"), opts.bcc.join(";"),
|
||||
opts.subj, opts.body, TQString::null, opts.attach);
|
||||
return true;
|
||||
}
|
||||
|
||||
// kate: replace-tabs true; tab-width 4; indent-width 4;
|
@ -0,0 +1,65 @@
|
||||
/*******************************************************************************
|
||||
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 __EMAIL_PORTAL_H
|
||||
#define __EMAIL_PORTAL_H
|
||||
|
||||
// Portal
|
||||
#include "interfaces/emailInterface.h"
|
||||
#include "interface.h"
|
||||
|
||||
struct EmailOpts
|
||||
{
|
||||
TQStringList rcpt;
|
||||
TQStringList cc;
|
||||
TQStringList bcc;
|
||||
TQString subj;
|
||||
TQString body;
|
||||
TQStringList attach;
|
||||
};
|
||||
|
||||
class TDEEmailPortal : public TQObject,
|
||||
public org::freedesktop::impl::portal::EmailInterface
|
||||
{
|
||||
public:
|
||||
INTERFACE("org.freedesktop.impl.portal.Email")
|
||||
|
||||
TDEEmailPortal(TQT_DBusConnection &connection);
|
||||
virtual ~TDEEmailPortal();
|
||||
|
||||
protected:
|
||||
virtual void handleMethodReply(const TQT_DBusMessage& reply);
|
||||
virtual bool handleSignalSend(const TQT_DBusMessage& reply);
|
||||
|
||||
virtual bool ComposeEmail(const TQT_DBusObjectPath& handle,
|
||||
const TQString& app_id,
|
||||
const TQString& parent_window,
|
||||
const TQT_DBusVariantMap& options,
|
||||
TQ_UINT32& response,
|
||||
TQT_DBusVariantMap &results,
|
||||
TQT_DBusError& error);
|
||||
private:
|
||||
TQT_DBusConnection m_connection;
|
||||
};
|
||||
|
||||
#endif // __EMAIL_PORTAL_H
|
||||
|
||||
// kate: replace-tabs true; tab-width 4; indent-width 4;
|
@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
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!
|
||||
*******************************************************************************/
|
||||
|
||||
/* Common definitions and includes for portal interfaces */
|
||||
#ifndef __INTERFACE_H_
|
||||
#define __INTERFACE_H_
|
||||
|
||||
// TQt
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbusmessage.h>
|
||||
#include <tqdbusvariant.h>
|
||||
#include <tqdbusdatalist.h>
|
||||
#include <tqdbusdata.h>
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqobject.h>
|
||||
|
||||
// Portal
|
||||
#include "util.h"
|
||||
|
||||
#define INTERFACE(x) \
|
||||
public: \
|
||||
static const TQCString interface() { return x; }
|
||||
|
||||
|
||||
#define OPTION_VALID(opt, sig) \
|
||||
options.keys().contains(opt) && check_variant(options[opt], sig)
|
||||
|
||||
#endif // __INTERFACE_H_
|
@ -0,0 +1,117 @@
|
||||
/*******************************************************************************
|
||||
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!
|
||||
*******************************************************************************/
|
||||
|
||||
// TDE
|
||||
#include <kdebug.h>
|
||||
|
||||
// Portal
|
||||
#include "util.h"
|
||||
|
||||
bool check_variant(TQT_DBusVariant variant, TQString signature)
|
||||
{
|
||||
return !variant.signature.isNull() && variant.signature == signature;
|
||||
}
|
||||
|
||||
TQString bytelist_to_string(TQT_DBusDataList list)
|
||||
{
|
||||
if (list.type() != TQT_DBusData::Byte) return TQString::null;
|
||||
TQCString bytes;
|
||||
TQValueList<TQ_UINT8> vl = list.toByteList();
|
||||
TQValueList<TQ_UINT8>::iterator vlit;
|
||||
for (vlit = vl.begin(); vlit != vl.end(); ++vlit)
|
||||
{
|
||||
bytes += (*vlit);
|
||||
}
|
||||
return TQString::fromLocal8Bit(bytes.data(), bytes.size());
|
||||
}
|
||||
|
||||
TQT_DBusDataList string_to_bytelist(TQString str)
|
||||
{
|
||||
TQCString bytes = str.latin1();
|
||||
TQValueList<TQ_UINT8> vl;
|
||||
char *bit;
|
||||
for (bit = bytes.begin(); bit != bytes.end(); ++bit)
|
||||
{
|
||||
vl << (TQ_UINT8)(*bit);
|
||||
}
|
||||
return TQT_DBusDataList(vl);
|
||||
}
|
||||
|
||||
TQT_DBusDataList kurl_list_to_datalist(KURL::List urls)
|
||||
{
|
||||
return TQT_DBusDataList(urls.toStringList());
|
||||
}
|
||||
|
||||
bool make_variant(TQVariant variant, TQT_DBusVariant &other)
|
||||
{
|
||||
TQString signature;
|
||||
switch (variant.type()) {
|
||||
case TQVariant::String:
|
||||
case TQVariant::Color:
|
||||
case TQVariant::Font:
|
||||
case TQVariant::Date:
|
||||
case TQVariant::DateTime:
|
||||
case TQVariant::Time:
|
||||
case TQVariant::KeySequence:
|
||||
other.signature = "s";
|
||||
other.value = TQT_DBusData::fromString(variant.toString());
|
||||
break;
|
||||
|
||||
case TQVariant::Int:
|
||||
other.signature = "i";
|
||||
other.value = TQT_DBusData::fromInt32(variant.toInt());
|
||||
break;
|
||||
|
||||
case TQVariant::UInt:
|
||||
other.signature = "u";
|
||||
other.value = TQT_DBusData::fromUInt32(variant.toUInt());
|
||||
break;
|
||||
|
||||
case TQVariant::Double:
|
||||
case TQVariant::LongLong:
|
||||
case TQVariant::ULongLong:
|
||||
other.signature = "d";
|
||||
other.value = TQT_DBusData::fromDouble(variant.toDouble());
|
||||
break;
|
||||
|
||||
case TQVariant::Bool:
|
||||
other.signature = "b";
|
||||
other.value = TQT_DBusData::fromBool(variant.toBool());
|
||||
break;
|
||||
|
||||
case TQVariant::StringList:
|
||||
other.signature = "as";
|
||||
other.value = TQT_DBusData::fromList(TQT_DBusDataList(variant.toStringList()));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (variant.canCast(TQVariant::String)) {
|
||||
other.signature = "s";
|
||||
other.value = TQT_DBusData::fromString(variant.toString());
|
||||
}
|
||||
else {
|
||||
kdDebug() << "Cannot cast TQVariant of type " << variant.type()
|
||||
<< "to TQT_DBusVariant!" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
Loading…
Reference in new issue