I have made the following changes intended for :
  CE:MW:Shared / libngf-qt

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.pub.meego.com//request/show/7731

Thank You,
John Brooks

[This message was auto-generated]

---

Request # 7731:

Messages from BOSS:

State: review at 2013-01-25T06:09:02 by bossbot

Reviews:
       accepted by bossbot : Prechecks succeeded.
       new for CE-maintainers : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:special:branches:CE:MW:Shared / libngf-qt -> CE:MW:Shared / 
libngf-qt
  
changes files:
--------------
--- libngf-qt.changes
+++ libngf-qt.changes
@@ -0,0 +1,3 @@
+* Thu Jan 24 2013 John Brooks <[email protected]> - 0.2
+- Add declarative NGF client plugin
+

old:
----
  libngf-qt-0.1.tar.gz

new:
----
  libngf-qt-0.2.tar.bz2

spec files:
-----------
--- libngf-qt.spec
+++ libngf-qt.spec
@@ -9,18 +9,19 @@
 # << macros
 
 Summary:    Qt-based client library for Non-Graphic Feedback daemon
-Version:    0.1
+Version:    0.2
 Release:    1
 Group:      System/Libraries
 License:    LGPLv2.1
 URL:        https://github.com/nemomobile/libngf-qt
-Source0:    %{name}-%{version}.tar.gz
+Source0:    %{name}-%{version}.tar.bz2
 Source100:  libngf-qt.yaml
 Requires:   ngfd
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 BuildRequires:  pkgconfig(QtCore)
 BuildRequires:  pkgconfig(QtDBus)
+BuildRequires:  pkgconfig(QtDeclarative)
 BuildRequires:  doxygen
 
 %description
@@ -36,9 +37,17 @@
 %description devel
 %{summary}.
 
+%package declarative
+Summary:    Declarative plugin for NGF clients
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description declarative
+%{summary}.
+
 
 %prep
-%setup -q -n %{name}-%{version}
+%setup -q -n %{name}
 
 # >> setup
 # << setup
@@ -86,3 +95,9 @@
 %{_libdir}/pkgconfig/ngf-qt.pc
 %{_mandir}/man3/Ngf_Client.3.gz
 # << files devel
+
+%files declarative
+%defattr(-,root,root,-)
+# >> files declarative
+%{_libdir}/qt4/imports/org/nemomobile/ngf/*
+# << files declarative

other changes:
--------------

++++++ libngf-qt-0.1.tar.gz -> libngf-qt-0.2.tar.bz2
--- .gitignore
+++ .gitignore
@@ -0,0 +1,5 @@
+*.o
+moc_*
+Makefile
+*.so*
+ngf-qt-client
--- README
+++ README
@@ -1,6 +1,8 @@
 Ngf::Client
 ===========
 
+Source: https://github.com/nemomobile/libngf-qt
+
 Qt-based client for NGF daemon (Non-Graphic Feedback).
 
 See src/include/ngfclient.h for API documentation.
--- declarative
+++ declarative
+(directory)
--- declarative/declarative.pro
+++ declarative/declarative.pro
@@ -0,0 +1,23 @@
+TARGET = libngf-declarative
+PLUGIN_IMPORT_PATH = org/nemomobile/ngf
+
+LIBS += -L../src/ \
+    -lngf-qt
+
+INCLUDEPATH += ../src/include
+
+SOURCES += src/plugin.cpp \
+    src/declarativengfevent.cpp
+
+HEADERS += src/declarativengfevent.h
+
+TEMPLATE = lib
+CONFIG += qt plugin hide_symbols
+QT += declarative
+
+target.path = $$[QT_INSTALL_IMPORTS]/$$PLUGIN_IMPORT_PATH
+INSTALLS += target
+
+qmldir.files += $$PWD/qmldir
+qmldir.path +=  $$[QT_INSTALL_IMPORTS]/$$$$PLUGIN_IMPORT_PATH
+INSTALLS += qmldir
--- declarative/qmldir
+++ declarative/qmldir
@@ -0,0 +1 @@
+plugin libngf-declarative
--- declarative/src
+++ declarative/src
+(directory)
--- declarative/src/declarativengfevent.cpp
+++ declarative/src/declarativengfevent.cpp
@@ -0,0 +1,162 @@
+/* Copyright (C) 2013 Jolla Ltd.
+ * Contact: John Brooks <[email protected]>
+ *
+ * This work is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This work 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 work; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 
USA
+ */
+
+#include "declarativengfevent.h"
+#include <NgfClient>
+
+static QSharedPointer<Ngf::Client> clientInstance()
+{
+    static QWeakPointer<Ngf::Client> client;
+
+    QSharedPointer<Ngf::Client> re = client.toStrongRef();
+    if (re.isNull()) {
+        re = QSharedPointer<Ngf::Client>(new Ngf::Client);
+        client = re.toWeakRef();
+    }
+
+    return re;
+}
+
+DeclarativeNgfEvent::DeclarativeNgfEvent(QObject *parent)
+    : QObject(parent), client(clientInstance()), m_status(Stopped), 
m_eventId(0), m_autostart(false)
+{
+    connect(client.data(), SIGNAL(connectionStatus(bool)), 
SLOT(connectionStatusChanged(bool)));
+    connect(client.data(), SIGNAL(eventFailed(quint32)), 
SLOT(eventFailed(quint32)));
+    connect(client.data(), SIGNAL(eventCompleted(quint32)), 
SLOT(eventCompleted(quint32)));
+    connect(client.data(), SIGNAL(eventPlaying(quint32)), 
SLOT(eventPlaying(quint32)));
+    connect(client.data(), SIGNAL(eventPaused(quint32)), 
SLOT(eventPaused(quint32)));
+}
+
+DeclarativeNgfEvent::~DeclarativeNgfEvent()
+{
+    stop();
+}
+
+void DeclarativeNgfEvent::setEvent(const QString &event)
+{
+    if (m_event == event)
+        return;
+
+    if (m_eventId) {
+        stop();
+        m_autostart = true;
+    }
+
+    m_event = event;
+
+    emit eventChanged();
+    if (m_autostart)
+        play();
+}
+
+void DeclarativeNgfEvent::play()
+{
+    if (!isConnected())
+        client->connect();
+
+    m_autostart = true;
+
+    if (m_eventId)
+        stop();
+
+    if (!m_event.isEmpty() && isConnected())
+        m_eventId = client->play(m_event);
+}
+
+void DeclarativeNgfEvent::pause()
+{
+    if (!m_eventId)
+        return;
+
+    client->pause(m_eventId);
+}
+
+void DeclarativeNgfEvent::resume()
+{
+    if (!m_eventId)
+        return;
+
+    client->resume(m_eventId);
+}
+
+void DeclarativeNgfEvent::stop()
+{
+    m_autostart = false;
+
+    if (!m_eventId)
+        return;
+
+    client->stop(m_eventId);
+    m_eventId = 0;
+    m_status = Stopped;
+    emit statusChanged();
+}
+
+bool DeclarativeNgfEvent::isConnected() const
+{
+    return client->isConnected();
+}
+
+void DeclarativeNgfEvent::connectionStatusChanged(bool connected)
+{
+    if (connected && m_autostart) {
+        m_autostart = false;
+        play();
+    }
+
+    emit connectedChanged();
+}
+
+void DeclarativeNgfEvent::eventFailed(quint32 id)
+{
+    if (id != m_eventId)
+        return;
+
+    m_eventId = 0;
+    m_status = Failed;
+    emit statusChanged();
+}
+
+void DeclarativeNgfEvent::eventCompleted(quint32 id)
+{
+    if (id != m_eventId)
+        return;
+
+    m_eventId = 0;
+    m_status = Stopped;
+    emit statusChanged();
+}
+
+void DeclarativeNgfEvent::eventPlaying(quint32 id)
+{
+    if (id != m_eventId)
+        return;
+
+    m_status = Playing;
+    m_autostart = false;
+    emit statusChanged();
+}
+
+void DeclarativeNgfEvent::eventPaused(quint32 id)
+{
+    if (id != m_eventId)
+        return;
+
+    m_status = Paused;
+    emit statusChanged();
+}
+
--- declarative/src/declarativengfevent.h
+++ declarative/src/declarativengfevent.h
@@ -0,0 +1,150 @@
+/* Copyright (C) 2013 Jolla Ltd.
+ * Contact: John Brooks <[email protected]>
+ *
+ * This work is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This work 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 work; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 
USA
+ */
+
+#ifndef DECLARATIVENGFEVENT_H
+#define DECLARATIVENGFEVENT_H
+
+#include <QObject>
+#include <QSharedPointer>
+
+namespace Ngf {
+    class Client;
+}
+
+/*!
+   \qmlclass NonGraphicalFeedback DeclarativeNgfEvent
+   \brief Playback of non-graphical feedback events
+ 
+   NonGraphicalFeedback allows playback of system-defined events via the ngf
+   daemon, such as notification sounds and effects.
+ 
+   An event's actions are defined by a string which is mapped to configuration
+   files installed on the system. Examples include "ringtone", "chat", or 
"battery_low".
+ 
+   \qml
+   NonGraphicalFeedback {
+       id: ringtone
+       event: "ringtone"
+
+       Connections {
+           target: phone
+           onIncomingCall: ringtone.play()
+           onCallAnswered: ringtone.stop()
+       }
+   }
+   \endqml
+ */
+
+class DeclarativeNgfEvent : public QObject
+{
+    Q_OBJECT
+    Q_ENUMS(EventStatus)
+
+public:
+    enum EventStatus {
+        Stopped,
+        Failed,
+        Playing,
+        Paused
+    };
+
+    DeclarativeNgfEvent(QObject *parent = 0);
+    virtual ~DeclarativeNgfEvent();
+
+    /*!
+       \qmlproperty bool connected
+
+       Indicates if the NGF daemon is connected and active. The connection
+       will be established automatically when needed.
+     */
+    Q_PROPERTY(bool connected READ isConnected NOTIFY connectedChanged)
+    bool isConnected() const;
+
+    /*!
+       \qmlproperty string event
+
+       Set the NGF event name. Events are defined in system-installed 
configuration files
+       with a short name like "ringtone" or "battery_low".
+
+       If the event is changed while playing, playback will be restarted
+       automatically with the new event.
+     */
+    Q_PROPERTY(QString event READ event WRITE setEvent NOTIFY eventChanged)
+    QString event() const { return m_event; }
+    void setEvent(const QString &event);
+
+    /*!
+       \qmlproperty EventStatus status
+
+       Current status of playback. This property is updated asynchronously 
after
+       requests to play, pause, or stop the event.
+     */
+    Q_PROPERTY(EventStatus status READ status NOTIFY statusChanged)
+    EventStatus status() const { return m_status; }
+
+public slots:
+    /*!
+       \qmlmethod void NonGraphicalFeedback::play()
+
+       Begins playing the defined event. If already playing, playback will be
+       restarted from the beginning.
+
+       Actual playback happens asynchronously. The \c status property will 
change
+       when playback begins and ends, or in case of failure.
+     */
+    void play();
+    /*!
+       \qmlmethod void NonGraphicalFeedback::pause()
+
+       Pause the currently playing event. Playback can be resumed with \a 
resume()
+     */
+    void pause();
+    /*!
+       \qmlmethod void NonGraphicalFeedback::resume()
+
+       Resume a paused event.
+     */
+    void resume();
+    /*!
+       \qmlmethod void NonGraphicalFeedback::stop()
+
+       Stop playback of the event.
+     */
+    void stop();
+
+signals:
+    void connectedChanged();
+    void eventChanged();
+    void statusChanged();
+
+private slots:
+    void connectionStatusChanged(bool connected);
+    void eventFailed(quint32 id);
+    void eventCompleted(quint32 id);
+    void eventPlaying(quint32 id);
+    void eventPaused(quint32 id);
+
+private:
+    QSharedPointer<Ngf::Client> client;
+    QString m_event;
+    EventStatus m_status;
+    quint32 m_eventId;
+    bool m_autostart;
+};
+
+#endif
+
--- declarative/src/plugin.cpp
+++ declarative/src/plugin.cpp
@@ -0,0 +1,45 @@
+/* Copyright (C) 2013 Jolla Ltd.
+ * Contact: John Brooks <[email protected]>
+ *
+ * This work is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This work 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 work; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 
USA
+ */
+
+#include <QtGlobal>
+#include <QtDeclarative>
+#include <QDeclarativeEngine>
+#include <QDeclarativeExtensionPlugin>
+#include "declarativengfevent.h"
+
+class Q_DECL_EXPORT NgfPlugin : public QDeclarativeExtensionPlugin
+{
+public:
+    virtual ~NgfPlugin() { }
+
+    void initializeEngine(QDeclarativeEngine *engine, const char *uri)
+    {
+        Q_ASSERT(uri == QLatin1String("org.nemomobile.ngf"));
+        Q_UNUSED(uri);
+        Q_UNUSED(engine);
+    }
+
+    void registerTypes(const char *uri)
+    {
+        Q_ASSERT(uri == QLatin1String("org.nemomobile.ngf"));
+
+        qmlRegisterType<DeclarativeNgfEvent>(uri, 1, 0, 
"NonGraphicalFeedback");
+    }
+};
+
+Q_EXPORT_PLUGIN2(ngfplugin, NgfPlugin);
+
--- project.pro
+++ project.pro
@@ -3,7 +3,7 @@
     PREFIX = /usr/local
 }
 TEMPLATE = subdirs
-SUBDIRS += src
+SUBDIRS += src declarative
 
 # No need to build this, but if you want then 'qmake EXAMPLE=1 && make'
 count(EXAMPLE, 1) {

++++++ libngf-qt.yaml
--- libngf-qt.yaml
+++ libngf-qt.yaml
@@ -1,12 +1,12 @@
 Name: libngf-qt
 Summary: Qt-based client library for Non-Graphic Feedback daemon
-Version: 0.1
+Version: 0.2
 Release: 1
 Group: System/Libraries
 License: LGPLv2.1
 URL: https://github.com/nemomobile/libngf-qt
 Sources:
-    - "%{name}-%{version}.tar.gz"
+    - "%{name}-%{version}.tar.bz2"
 Description: |
     This package contains the Qt-based client library for accessing
     Non-graphic feedback services.
@@ -18,6 +18,7 @@
 PkgConfigBR:
     - QtCore
     - QtDBus
+    - QtDeclarative
 Configure: none
 Builder: make
 SubPackages:
@@ -26,3 +27,7 @@
       Group: Development/Libraries
       Description: "%{summary}."
 
+    - Name: declarative
+      Summary: Declarative plugin for NGF clients
+      Group: Development/Libraries
+      Description: "%{summary}."



Reply via email to