# ECM setup
find_package(ECM ${ECM_MIN_VERSION} CONFIG REQUIRED)
-set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
COMPONENT Devel
)
+configure_file(org.kde.dolphin.FileManager1.service.in
+ ${CMAKE_CURRENT_BINARY_DIR}/org.kde.dolphin.FileManager1.service)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.dolphin.FileManager1.service
+ DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
+
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
--- /dev/null
+macro (generate_and_install_dbus_interface main_project_target header_file output_xml_file)
+ qt5_generate_dbus_interface(
+ ${header_file}
+ ${output_xml_file}
+ )
+ add_custom_target(
+ ${output_xml_file}
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${output_xml_file}
+ )
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/${output_xml_file}
+ DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}
+ )
+ add_dependencies(
+ ${main_project_target}
+ ${output_xml_file}
+ )
+endmacro ()
--- /dev/null
+[D-BUS Service]
+Name=org.freedesktop.FileManager1
+Exec=@CMAKE_INSTALL_PREFIX@/bin/dolphin --daemon
statusbar/statusbarspaceinfo.cpp
views/zoomlevelinfo.cpp
dolphindebug.cpp
+ dbusinterface.cpp
+ global.cpp
)
kconfig_add_kcfg_files(dolphin_SRCS GENERATE_MOC
)
endif()
+include(DbusInterfaceMacros)
+
+generate_and_install_dbus_interface(
+ kdeinit_dolphin
+ dbusinterface.h
+ org.freedesktop.FileManager1.xml
+ OPTIONS -a
+)
+
install(TARGETS kdeinit_dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
--- /dev/null
+/*
+ * Copyright 2015 Ashish Bansal<bansal.ashish096@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "dbusinterface.h"
+#include "global.h"
+
+#include <QDBusConnection>
+#include <QList>
+#include <QUrl>
+#include <KPropertiesDialog>
+#include <KRun>
+
+DBusInterface::DBusInterface() :
+ QObject()
+{
+ QDBusConnection::sessionBus().registerService("org.freedesktop.FileManager1");
+ QDBusConnection::sessionBus().registerObject("/org/freedesktop/FileManager1", this,
+ QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
+}
+
+void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId)
+{
+ Q_UNUSED(startUpId);
+ const QList<QUrl> urls = Dolphin::validateUris(uriList);
+ if (urls.isEmpty()) {
+ return;
+ }
+ KRun::run("dolphin %u", urls, nullptr);
+}
+
+void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId)
+{
+ Q_UNUSED(startUpId);
+ const QList<QUrl> urls = Dolphin::validateUris(uriList);
+ if (urls.isEmpty()) {
+ return;
+ }
+ KRun::run("dolphin --select %u", urls, nullptr);
+}
+
+void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId)
+{
+ Q_UNUSED(startUpId);
+ const QList<QUrl> urls = Dolphin::validateUris(uriList);
+ foreach (const QUrl& url, urls) {
+ KPropertiesDialog::showDialog(url);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 Ashish Bansal<bansal.ashish096@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DBUSINTERFACE_H
+#define DBUSINTERFACE_H
+
+#include <QObject>
+
+class DBusInterface : QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.FileManager1")
+
+public:
+ DBusInterface();
+ Q_SCRIPTABLE void ShowFolders(const QStringList& uriList, const QString& startUpId);
+ Q_SCRIPTABLE void ShowItems(const QStringList& uriList, const QString& startUpId);
+ Q_SCRIPTABLE void ShowItemProperties(const QStringList& uriList, const QString& startUpId);
+};
+
+#endif // DBUSINTERFACE_H
--- /dev/null
+/*
+ * Copyright 2015 Ashish Bansal<bansal.ashish096@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "global.h"
+#include "dolphindebug.h"
+
+QList<QUrl> Dolphin::validateUris(const QStringList& uriList)
+{
+ QList<QUrl> urls;
+ foreach (const QString& str, uriList) {
+ const QUrl url = QUrl::fromUserInput(str, QString(), QUrl::AssumeLocalFile);
+ if (url.isValid()) {
+ urls.append(url);
+ } else {
+ qCWarning(DolphinDebug) << "Invalid URL: " << str;
+ }
+ }
+ return urls;
+}
--- /dev/null
+/*
+ * Copyright 2015 Ashish Bansal<bansal.ashish096@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+#include <QList>
+#include <QUrl>
+
+namespace Dolphin {
+ QList<QUrl> validateUris(const QStringList& uriList);
+}
+
+#endif //GLOBAL_H
#include "dolphinmainwindow.h"
#include "dolphin_generalsettings.h"
+#include "dbusinterface.h"
+#include "global.h"
#include <KDBusService>
#include <KAboutData>
KAboutData::setApplicationData(aboutData);
KDBusService dolphinDBusService;
+ DBusInterface interface;
QCommandLineParser parser;
parser.addVersionOption();
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("select"), i18nc("@info:shell", "The files and directories passed as arguments "
"will be selected.")));
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
+ parser.addOption(QCommandLineOption(QStringList() << QLatin1String("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface)")));
parser.addPositionalArgument(QLatin1String("+[Url]"), i18nc("@info:shell", "Document to open"));
parser.process(app);
aboutData.processCommandLine(&parser);
+ if (parser.isSet("daemon")) {
+ return app.exec();
+ }
DolphinMainWindow* m_mainWindow = new DolphinMainWindow();
m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
- QList<QUrl> urls;
const QStringList args = parser.positionalArguments();
- foreach (const QString& str, args) {
- const QUrl url = QUrl::fromUserInput(str, QString(), QUrl::AssumeLocalFile);
- if (url.isValid()) {
- urls.append(url);
- } else {
- qCWarning(DolphinDebug) << "Invalid URL: " << str;
- }
- }
+ QList<QUrl> urls = Dolphin::validateUris(args);
bool resetSplitSettings = false;
if (parser.isSet("split") && !GeneralSettings::splitView()) {