Ported ShareHelper to ShareUiInterface
authorMohammed Sameer <msameer@foolab.org>
Fri, 28 Dec 2012 09:25:23 +0000 (11:25 +0200)
committerMohammed Sameer <msameer@foolab.org>
Fri, 28 Dec 2012 09:25:23 +0000 (11:25 +0200)
qml/PostCapturePage.qml
src/sharehelper.cpp
src/sharehelper.h
src/src.pro

index d5e4516..0d1a337 100644 (file)
@@ -79,7 +79,9 @@ CameraPage {
                         return;
                 }
 
-                share.share(currentItem.itemUrl);
+                if (!share.share(currentItem.itemUrl)) {
+                                showError(qsTr("Failed to launch share service"));
+                }
         }
 
         ShareHelper {
index 74470ba..2df15d0 100644 (file)
  */
 
 #include "sharehelper.h"
-#include <QDBusInterface>
+#include <maemo-meegotouch-interfaces/shareuiinterface.h>
 #include <QStringList>
 #include <QUrl>
 #include <QDeclarativeInfo>
 
 ShareHelper::ShareHelper(QObject *parent) :
-  QObject(parent) {
+  QObject(parent),
+  m_iface(new ShareUiInterface) {
 
 }
 
 ShareHelper::~ShareHelper() {
-
+  delete m_iface;
 }
 
-void ShareHelper::share(const QUrl& path) {
-  QDBusInterface iface("com.nokia.ShareUi", "/", "com.nokia.maemo.meegotouch.ShareUiInterface",
-                      QDBusConnection::sessionBus());
+bool ShareHelper::share(const QUrl& path) {
+  if (!m_iface->isValid()) {
+    qmlInfo(this) << "Failed to get share interface";
+    return false;
+  }
+
+  m_iface->share(QStringList() << path.toLocalFile());
 
-  iface.call("share", QStringList() << path.toLocalFile());
+  return true;
 }
index 4e42e87..8a391de 100644 (file)
@@ -26,6 +26,7 @@
 #include <QObject>
 
 class QUrl;
+class ShareUiInterface;
 
 class ShareHelper : public QObject {
   Q_OBJECT
@@ -34,8 +35,10 @@ public:
   ShareHelper(QObject *parent = 0);
   ~ShareHelper();
 
-public slots:
-  void share(const QUrl& path);
+  Q_INVOKABLE bool share(const QUrl& path);
+
+private:
+  ShareUiInterface *m_iface;
 };
 
 #endif /* SHARE_HELPER_H */
index 01ca649..d61b5ff 100644 (file)
@@ -10,7 +10,8 @@ CONFIG += link_pkgconfig debug static mobility qtsparql
 MOBILITY += location
 
 PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-tag-0.10 \
-            gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 quill qmsystem2 libresourceqt1
+            gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 quill qmsystem2 libresourceqt1 \
+            ShareUiInterface-maemo-meegotouch
 
 LIBS +=  -L../imports/ -limports -L../lib/ -lqtcamera