Drop share ui and gallery usage via interfaces and use configurable DBus method calls
instead.
This drops 2 harmattan specific packages from our dependencies.
# temporaryFilePath =
dbusThumbnailingEnabled = true
thumbnailCreationEnabled = true
+
+[gallery]
+enabled = true
+type = dbus
+path = /
+interface = com.nokia.maemo.meegotouch.GalleryInterface
+dest = com.nokia.Gallery
+method = camera-roll:showCameraRoll|show-media:showMediaInFullScreen
+
+[share]
+enabled = true
+type = dbus
+path = /
+interface = com.nokia.maemo.meegotouch.ShareUiInterface
+dest = com.nokia.ShareUi
+method = share:share
libquill-dev, meego-gstreamer0.10-interfaces-dev, libgstreamer0.10-dev,
libgstreamer-plugins-base0.10-dev, gstreamer0.10-plugins-bad-dev,
libcanberra-dev, libcontextsubscriber-dev, libqtm-location-dev,
- libqtsparql-dev, maemo-meegotouch-interfaces-dev, libqtm-systeminfo-dev,
+ libqtsparql-dev, libqtm-systeminfo-dev,
aegis-builder
Standards-Version: 3.9.1
ShareHelper {
id: share
+ settings: platformSettings
}
GalleryHelper {
id: gallery
+ settings: platformSettings
}
Rectangle {
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This 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
+ */
+
+#include "dbusservice.h"
+#include <QDBusInterface>
+#include "platformsettings.h"
+#include <QDeclarativeInfo>
+#include <QDBusPendingCall>
+
+// We cannot use ADBusInterface because it will try to introspect the service upon
+// creation. This will lead to services being launched when we create the interfaces.
+DbusService::DbusService(QObject *parent) :
+ QObject(parent), m_settings(0), m_enabled(false) {
+
+}
+
+DbusService::~DbusService() {
+
+}
+
+PlatformSettings *DbusService::settings() const {
+ return m_settings;
+}
+
+void DbusService::setSettings(PlatformSettings *settings) {
+ if (m_settings != settings) {
+ m_settings = settings;
+
+ init();
+
+ emit settingsChanged();
+ }
+}
+
+void DbusService::setName(const QString& name) {
+ if (m_name != name) {
+ m_name = name;
+
+ init();
+
+ emit nameChanged();
+ }
+}
+
+bool DbusService::isEnabled() const {
+ return m_enabled;
+}
+
+void DbusService::init() {
+ if (m_name.isEmpty() || !m_settings) {
+ return;
+ }
+
+ PlatformSettings::Service service = m_settings->service(m_name);
+
+ if (service.m_type != "dbus") {
+ qmlInfo(this) << "Unknown service type" << service.m_type;
+ return;
+ }
+
+ if (!service.m_enabled) {
+ qmlInfo(this) << "Not initializing a disabled service";
+ return;
+ }
+
+ m_path = service.m_path;
+ m_interface = service.m_interface;
+ m_dest = service.m_dest;
+
+ QStringList methods = service.m_method.split('|');
+ foreach (const QString& method, methods) {
+ QStringList parts = method.split(':');
+ if (parts.size() != 2) {
+ qmlInfo(this) << "Cannot parse dbus method description" << method;
+ continue;
+ }
+
+ QString id = parts[0].trimmed();
+ QString val = parts[1].trimmed();
+ if (id.isEmpty() || val.isEmpty()) {
+ qmlInfo(this) << "Empty id or value";
+ continue;
+ }
+
+ m_methods[id] = val;
+ }
+
+ m_enabled = service.m_enabled;
+ emit isEnabledChanged();
+}
+
+bool DbusService::asyncCall(const QString& method, const QVariant& arg) {
+ if (!m_settings) {
+ qmlInfo(this) << "Empty settings.";
+ return false;
+ }
+
+ if (!m_enabled) {
+ qmlInfo(this) << "Service is not enabled.";
+ return false;
+ }
+
+ if (m_dest.isEmpty() || m_path.isEmpty() || m_interface.isEmpty()) {
+ qmlInfo(this) << "Unable to construct DBus method call.";
+ return false;
+ }
+
+ if (method.isEmpty()) {
+ qmlInfo(this) << "Empty method call";
+ return false;
+ }
+
+ if (!m_methods.contains(method)) {
+ qmlInfo(this) << "Unknown method call ID" << method;
+ return false;
+ }
+
+ QString call = m_methods[method];
+
+ QDBusMessage msg = QDBusMessage::createMethodCall(m_dest, m_path, m_interface, call);
+ msg.setAutoStartService(true);
+ if (arg.isValid()) {
+ msg.setArguments(QList<QVariant>() << arg);
+ }
+
+ QDBusConnection conn = QDBusConnection::sessionBus();
+ if (!conn.isConnected()) {
+ qmlInfo(this) << "Unable to connect to DBus session bus.";
+ return false;
+ }
+
+ conn.asyncCall(msg);
+
+ return true;
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This 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
+ */
+
+#ifndef DBUS_SERVICE_H
+#define DBUS_SERVICE_H
+
+#include <QObject>
+#include <QVariant>
+#include <QHash>
+
+class PlatformSettings;
+
+class DbusService : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(PlatformSettings* settings READ settings WRITE setSettings NOTIFY settingsChanged);
+ Q_PROPERTY(bool enabled READ isEnabled NOTIFY isEnabledChanged);
+
+public:
+ DbusService(QObject *parent = 0);
+ ~DbusService();
+
+ PlatformSettings *settings() const;
+ void setSettings(PlatformSettings *settings);
+
+ void setName(const QString& name);
+
+ bool isEnabled() const;
+
+ bool asyncCall(const QString& method, const QVariant& arg = QVariant());
+
+signals:
+ void settingsChanged();
+ void nameChanged();
+ void isEnabledChanged();
+
+private:
+ void init();
+
+ PlatformSettings *m_settings;
+ QString m_name;
+
+ QString m_path;
+ QString m_interface;
+ QString m_dest;
+
+ bool m_enabled;
+
+ QMap<QString, QString> m_methods;
+};
+
+#endif /* DBUS_SERVICE_H */
*/
#include "galleryhelper.h"
-#include <maemo-meegotouch-interfaces/galleryinterface.h>
#include <QStringList>
#include <QUrl>
-#include <QDeclarativeInfo>
GalleryHelper::GalleryHelper(QObject *parent) :
- QObject(parent),
- m_iface(new GalleryInterface) {
-
+ DbusService(parent) {
+ setName("gallery");
}
GalleryHelper::~GalleryHelper() {
- delete m_iface;
+
}
bool GalleryHelper::show(const QUrl& path) {
- if (!m_iface->isValid()) {
- qmlInfo(this) << "Failed to get gallery interface";
- return false;
- }
+ // TODO: this is not working and I don't know why.
+ QStringList args;
+ args << path.toLocalFile();
- return m_iface->showMediaInFullScreen(QStringList() << path.toLocalFile());
+ QVariant var(args);
+
+ return asyncCall("show-media", var);
}
bool GalleryHelper::launch() {
- if (!m_iface->isValid()) {
- qmlInfo(this) << "Failed to get gallery interface";
- return false;
- }
-
- return m_iface->showCameraRoll();
+ return asyncCall("camera-roll");
}
#ifndef GALLERY_HELPER_H
#define GALLERY_HELPER_H
-#include <QObject>
+#include "dbusservice.h"
class QUrl;
-class GalleryInterface;
-class GalleryHelper : public QObject {
+class GalleryHelper : public DbusService {
Q_OBJECT
public:
Q_INVOKABLE bool show(const QUrl& path);
Q_INVOKABLE bool launch();
-
-private:
- GalleryInterface *m_iface;
};
#endif /* GALLERY_HELPER_H */
#include "deviceinfo.h"
#include "devicekeys.h"
#include "platformsettings.h"
+#include "dbusservice.h"
#ifdef QMLJSDEBUGGER
#include "qt_private/qdeclarativedebughelper_p.h"
QDir().mkpath(tempPath);
Quill::setTemporaryFilePath(tempPath);
}
+
+PlatformSettings::Service PlatformSettings::service(const QString& id) {
+ PlatformSettings::Service service;
+ m_settings->beginGroup(id);
+
+ service.m_enabled = m_settings->value("enabled", false).toBool();
+ service.m_type = m_settings->value("type").toString();
+ service.m_path = m_settings->value("path").toString();
+ service.m_interface = m_settings->value("interface").toString();
+ service.m_dest = m_settings->value("dest").toString();
+ service.m_method = m_settings->value("method").toString();
+
+ m_settings->endGroup();
+
+ return service;
+}
PlatformSettings(QObject *parent = 0);
~PlatformSettings();
+ class Service {
+ public:
+ bool m_enabled;
+ QString m_type;
+ QString m_path;
+ QString m_interface;
+ QString m_dest;
+ QString m_method;
+ };
+
QSize previewSize();
QString thumbnailFlavorName();
bool isThumbnailCreationEnabled();
QString temporaryFilePath();
+ Service service(const QString& id);
+
public slots:
void init();
*/
#include "sharehelper.h"
-#include <maemo-meegotouch-interfaces/shareuiinterface.h>
#include <QStringList>
#include <QUrl>
-#include <QDeclarativeInfo>
+#include <QVariant>
ShareHelper::ShareHelper(QObject *parent) :
- QObject(parent),
- m_iface(new ShareUiInterface) {
+ DbusService(parent) {
+ setName("share");
}
ShareHelper::~ShareHelper() {
- delete m_iface;
}
bool ShareHelper::share(const QUrl& path) {
- if (!m_iface->isValid()) {
- qmlInfo(this) << "Failed to get share interface";
- return false;
- }
+ QStringList args;
+ args << path.toLocalFile();
- m_iface->share(QStringList() << path.toLocalFile());
+ QVariant var(args);
- return true;
+ return asyncCall("share", args);
}
#ifndef SHARE_HELPER_H
#define SHARE_HELPER_H
-#include <QObject>
+#include "dbusservice.h"
class QUrl;
-class ShareUiInterface;
-class ShareHelper : public QObject {
+class ShareHelper : public DbusService {
Q_OBJECT
public:
~ShareHelper();
Q_INVOKABLE bool share(const QUrl& path);
-
-private:
- ShareUiInterface *m_iface;
};
#endif /* SHARE_HELPER_H */
QT += declarative opengl dbus
-CONFIG += link_pkgconfig mobility qtsparql galleryinterface-maemo-meegotouch \
- shareuiinterface-maemo-meegotouch
+CONFIG += link_pkgconfig mobility qtsparql
MOBILITY += location systeminfo
cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \
postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.cpp devicekeys.cpp \
- platformsettings.cpp
+ platformsettings.cpp dbusservice.cpp
HEADERS += settings.h filenaming.h quillitem.h displaystate.h fsmonitor.h \
cameraresources.h compass.h orientation.h geocode.h mountprotector.h \
trackerstore.h focusrectangle.h sharehelper.h deletehelper.h galleryhelper.h \
postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h devicekeys.h \
- platformsettings.h
+ platformsettings.h dbusservice.h
RESOURCES += ../qml/qml.qrc