Summary: This allows compile-time checks for the main window dbus methods.
Test Plan: Same test plan as in D21691, D21666 and D25510.
Reviewers: #dolphin
Subscribers: kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D26214
qt5_add_resources(dolphinstatic_SRCS dolphin.qrc)
qt5_add_resources(dolphinstatic_SRCS dolphin.qrc)
+qt5_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/dolphinmainwindow.h org.kde.DolphinMainWindow.xml)
+qt5_add_dbus_adaptor(dolphinstatic_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.DolphinMainWindow.xml dolphinmainwindow.h DolphinMainWindow)
+qt5_add_dbus_interface(dolphinstatic_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.DolphinMainWindow.xml dolphinmainwindowinterface)
+
add_library(dolphinstatic STATIC ${dolphinstatic_SRCS})
target_include_directories(dolphinstatic SYSTEM PRIVATE ${PHONON_INCLUDES})
add_library(dolphinstatic STATIC ${dolphinstatic_SRCS})
target_include_directories(dolphinstatic SYSTEM PRIVATE ${PHONON_INCLUDES})
#include "dolphinmainwindow.h"
#include "dolphinmainwindow.h"
+#include "dolphinmainwindowadaptor.h"
#include "config-terminal.h"
#include "global.h"
#include "dolphinbookmarkhandler.h"
#include "config-terminal.h"
#include "global.h"
#include "dolphinbookmarkhandler.h"
m_forwardAction(nullptr)
{
Q_INIT_RESOURCE(dolphin);
m_forwardAction(nullptr)
{
Q_INIT_RESOURCE(dolphin);
+
+ new MainWindowAdaptor(this);
+
#ifndef Q_OS_WIN
setWindowFlags(Qt::WindowContextHelpButtonHint);
#endif
#ifndef Q_OS_WIN
setWindowFlags(Qt::WindowContextHelpButtonHint);
#endif
#include "dolphin_generalsettings.h"
#include "dolphindebug.h"
#include "dolphin_generalsettings.h"
#include "dolphindebug.h"
+#include "dolphinmainwindowinterface.h"
#include <KRun>
#include <KWindowSystem>
#include <QApplication>
#include <QIcon>
#include <KRun>
#include <KWindowSystem>
#include <QApplication>
#include <QIcon>
-#include <QDBusInterface>
-#include <QDBusConnectionInterface>
QList<QUrl> Dolphin::validateUris(const QStringList& uriList)
{
QList<QUrl> Dolphin::validateUris(const QStringList& uriList)
{
bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFiles, bool splitView, const QString& preferredService)
{
bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFiles, bool splitView, const QString& preferredService)
{
+ bool attached = false;
+
// TODO: once Wayland clients can raise or activate themselves remove check from conditional
if (KWindowSystem::isPlatformWayland() || inputUrls.isEmpty() || !GeneralSettings::openExternallyCalledFolderInNewTab()) {
return false;
}
// TODO: once Wayland clients can raise or activate themselves remove check from conditional
if (KWindowSystem::isPlatformWayland() || inputUrls.isEmpty() || !GeneralSettings::openExternallyCalledFolderInNewTab()) {
return false;
}
- QVector<QPair<QSharedPointer<QDBusInterface>, QStringList>> dolphinInterfaces;
+ QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces;
if (!preferredService.isEmpty()) {
if (!preferredService.isEmpty()) {
- QSharedPointer<QDBusInterface> preferredInterface(
- new QDBusInterface(preferredService,
- QStringLiteral("/dolphin/Dolphin_1"),
- QStringLiteral("org.kde.dolphin.MainWindow"))
- );
+ QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface(
+ new OrgKdeDolphinMainWindowInterface(preferredService,
+ QStringLiteral("/dolphin/Dolphin_1"),
+ QDBusConnection::sessionBus()));
if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
}
if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
}
for (const QString& service : dbusServices) {
if (service.startsWith(pattern) && !service.endsWith(myPid)) {
// Check if instance can handle our URLs
for (const QString& service : dbusServices) {
if (service.startsWith(pattern) && !service.endsWith(myPid)) {
// Check if instance can handle our URLs
- QSharedPointer<QDBusInterface> interface(
- new QDBusInterface(service,
- QStringLiteral("/dolphin/Dolphin_1"),
- QStringLiteral("org.kde.dolphin.MainWindow"))
- );
+ QSharedPointer<OrgKdeDolphinMainWindowInterface> interface(
+ new OrgKdeDolphinMainWindowInterface(service,
+ QStringLiteral("/dolphin/Dolphin_1"),
+ QDBusConnection::sessionBus()));
if (interface->isValid() && !interface->lastError().isValid()) {
dolphinInterfaces.append(qMakePair(interface, QStringList()));
}
if (interface->isValid() && !interface->lastError().isValid()) {
dolphinInterfaces.append(qMakePair(interface, QStringList()));
}
for (const QString& url : urls) {
bool urlFound = false;
for (auto& interface: dolphinInterfaces) {
for (const QString& url : urls) {
bool urlFound = false;
for (auto& interface: dolphinInterfaces) {
- QDBusReply<bool> isUrlOpenReply = interface.first->call(QStringLiteral("isUrlOpen"), url);
- if (isUrlOpenReply.isValid() && isUrlOpenReply.value()) {
+ auto isUrlOpenReply = interface.first->isUrlOpen(url);
+ isUrlOpenReply.waitForFinished();
+ if (!isUrlOpenReply.isError() && isUrlOpenReply.value()) {
interface.second.append(url);
urlFound = true;
break;
interface.second.append(url);
urlFound = true;
break;
for (const auto& interface: dolphinInterfaces) {
if (!interface.second.isEmpty()) {
for (const auto& interface: dolphinInterfaces) {
if (!interface.second.isEmpty()) {
- interface.first->call(openFiles ? QStringLiteral("openFiles") : QStringLiteral("openDirectories"), interface.second, splitView);
- interface.first->call(QStringLiteral("activateWindow"));
+ auto reply = openFiles ? interface.first->openFiles(interface.second, splitView) : interface.first->openDirectories(interface.second, splitView);
+ reply.waitForFinished();
+ if (!reply.isError()) {
+ interface.first->activateWindow();
+ attached = true;
+ }