I have made the following changes intended for :
  CE:Adaptation:N950-N9 / contextkit-plugins-n950-n9

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/6911

Thank You,
zalevski

[This message was auto-generated]

---

Request # 6911:

Messages from BOSS:

State: review at 2012-10-04T15:09:57 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:zalevski:branches:CE:Adaptation:N950-N9 / 
contextkit-plugins-n950-n9 -> CE:Adaptation:N950-N9 / contextkit-plugins-n950-n9
  
changes files:
--------------
--- contextkit-plugins-n950-n9.changes
+++ contextkit-plugins-n950-n9.changes
@@ -0,0 +1,4 @@
+* Thu Oct 04 2012 Denis Zalevskiy <[email protected]> - 0.7.38
+- kbslider: missed linking fix
+- fixing typo with upower version
+

old:
----
  contextkit-plugins-n950-n9-0.7.37.tar.bz2

new:
----
  contextkit-plugins-n950-n9-0.7.38.tar.bz2

spec files:
-----------
--- contextkit-plugins-n950-n9.spec
+++ contextkit-plugins-n950-n9.spec
@@ -1,7 +1,7 @@
 Name:       contextkit-plugins-n950-n9
 Summary:    N950/N9 specific ContextKit providers for Nemo Mobile
-Version:    0.7.37
-Release:    4
+Version:    0.7.38
+Release:    1
 Group:      Applications/System
 License:    LGPLv2
 URL:        https://github.com/nemomobile/contextkit-nemo
@@ -34,8 +34,8 @@
 Requires:   bme-rm-680-bin >= 0.9.95
 Obsoletes: contextkit-meego-battery-upower <= %{meego_ver}
 Provides: contextkit-meego-battery-upower = %{meego_ver1}
-Obsoletes: contextkit-plugin-upower <= %{meego_ver}
-Provides: contextkit-plugin-upower = %{meego_ver1}
+Obsoletes: contextkit-plugin-upower <= %{version}
+Provides: contextkit-plugin-upower = %{version}
 Provides:   %{g_power}
 %description %{p_power}
 %{summary}

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

++++++ contextkit-plugins-n950-n9-0.7.37.tar.bz2 -> 
contextkit-plugins-n950-n9-0.7.38.tar.bz2
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -47,6 +47,7 @@
 elseif(${PLATFORM} STREQUAL "NEMO_SHARED")
   add_subdirectory(maemo)
   add_subdirectory("meego/upower")
+  add_subdirectory("meego/keyboard-generic")
   add_subdirectory("meego/cellular")
   add_subdirectory("meego/connman")
   add_subdirectory("meego/phone")
--- include/cor
+++ include/cor
+(directory)
--- include/cor/udev.hpp
+++ include/cor/udev.hpp
@@ -0,0 +1,150 @@
+#ifndef _COR_UDEV_HPP_
+#define _COR_UDEV_HPP_
+/*
+ * Tiny libudev wrapper
+ *
+ * Copyright (C) 2012 Jolla Ltd.
+ * Contact: Denis Zalevskiy <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <libudev.h>
+#include <stddef.h>
+
+namespace cor {
+
+namespace udev {
+
+class Root
+{
+public:
+    Root() : p(udev_new()) {}
+    ~Root()
+    {
+        if (p)
+            udev_unref(p);
+    }
+
+    operator bool() const { return (p != 0); }
+
+    udev_device *mk_device(char const *path)
+    {
+        return udev_device_new_from_syspath(p, path);
+    }
+
+    struct udev_enumerate *mk_enumerate()
+    {
+        return udev_enumerate_new(p);
+    }
+
+private:
+    struct udev *p;
+};
+
+
+class Enumerate
+{
+public:
+    Enumerate(Root &root)
+        : p(root.mk_enumerate())
+    {}
+
+    ~Enumerate()
+    {
+        if (p)
+            udev_enumerate_unref(p);
+    }
+
+    operator bool() const { return (p != 0); }
+
+    void subsystem_add(char const *name)
+    {
+        udev_enumerate_add_match_subsystem(p, name);
+    }
+
+    struct udev_list_entry *devices()
+    {
+        udev_enumerate_scan_devices(p);
+        return udev_enumerate_get_list_entry(p);
+    }
+
+private:
+    struct udev_enumerate *p;
+};
+
+class ListEntry
+{
+public:
+    ListEntry(Enumerate &e)
+        : p(e.devices()) {}
+
+    ListEntry(struct udev_list_entry *p)
+        : p(p) {}
+
+    template <typename T>
+    void for_each(T const &fn)
+    {
+        struct udev_list_entry *entry;
+        udev_list_entry_foreach(entry, p) {
+            if (!fn(ListEntry(entry)))
+                break;
+        }
+    }
+
+    char const *path() const
+    {
+        return udev_list_entry_get_name(p);
+    }
+private:
+    struct udev_list_entry *p;
+};
+
+
+class Device
+{
+public:
+    Device(Root &root, char const *path)
+        : p(root.mk_device(path))
+    { }
+
+    operator bool() const { return (p != 0); }
+
+    ~Device()
+    {
+        if (!p)
+            udev_device_unref(p);
+    }
+
+    char const *attr(char const *name) const
+    {
+        return udev_device_get_sysattr_value(p, name);
+    }
+
+private:
+    struct udev_device *p;
+};
+
+} // namespace udev
+
+} // namespace cor
+
+#endif // _COR_UDEV_HPP_
--- maemo/kbslider/CMakeLists.txt
+++ maemo/kbslider/CMakeLists.txt
@@ -24,6 +24,6 @@
 qt4_wrap_cpp(MOC_SRC ${HDRS})
 
 add_ckit_plugin(${PROVIDER} MODULE ${SRC} ${MOC_SRC})
-TARGET_LINK_LIBRARIES(${PROVIDER} common)
+TARGET_LINK_LIBRARIES(${PROVIDER} ${UDEV_LIBRARIES} common)
 
 install(TARGETS ${PROVIDER} DESTINATION lib/contextkit/subscriber-plugins)
--- meego/keyboard-generic
+++ meego/keyboard-generic
+(directory)
--- meego/keyboard-generic/CMakeLists.txt
+++ meego/keyboard-generic/CMakeLists.txt
@@ -0,0 +1,31 @@
+pkg_check_modules(UDEV libudev)
+set(PROVIDER keyboard-generic)
+set(INTERFACE internal_keyboard)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+
+CKIT_GENERATE_CONTEXT(${INTERFACE} ${PROVIDER})
+CKIT_GENERATE_TEST_MAIN(${INTERFACE} ${PROVIDER})
+
+include_directories(
+  ${UDEV_INCLUDE_DIRS}
+)
+
+link_directories(
+  ${UDEV_LIBRARY_DIRS}
+)
+
+set(SRC
+  plugin.cpp
+  )
+
+set(HDRS
+  plugin.hpp
+  )
+
+qt4_wrap_cpp(MOC_SRC ${HDRS})
+
+add_ckit_plugin(${PROVIDER} MODULE ${SRC} ${MOC_SRC})
+TARGET_LINK_LIBRARIES(${PROVIDER} ${UDEV_LIBRARIES})
+
+install(TARGETS ${PROVIDER} DESTINATION lib/contextkit/subscriber-plugins)
--- meego/keyboard-generic/plugin.cpp
+++ meego/keyboard-generic/plugin.cpp
@@ -0,0 +1,142 @@
+/*
+ * Generic keyboard properties provider
+ *
+ * Copyright (C) 2012 Jolla Ltd.
+ * Contact: Denis Zalevskiy <[email protected]>
+ *
+ * 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
+ *
+ * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+ */
+
+#include <contextkit_props/internal_keyboard.hpp>
+#include <cor/udev.hpp>
+#include "plugin.hpp"
+
+#include <linux/input.h>
+
+#include <QString>
+#include <QStringList>
+#include <QVector>
+
+
+IProviderPlugin* pluginFactory(const QString&)
+{
+    return new ContextKitNemo::KeyboardGeneric();
+}
+
+namespace ContextKitNemo
+{
+
+static bool isKeyboardDevice(cor::udev::Device const &dev)
+{
+    QString key(dev.attr("capabilities/key"));
+    QStringList caps_strs(key.split(' ', QString::SkipEmptyParts));
+    if (caps_strs.isEmpty())
+        return false;
+    QVector<unsigned long> caps;
+    foreach(QString const &s, caps_strs) {
+        unsigned long v;
+        bool is_ok = false;
+        v = s.toULong(&is_ok, 16);
+        if (!is_ok)
+            return false;
+        caps.push_back(v);
+    }
+    size_t count = 0;
+    for (unsigned i = KEY_Q; i <= KEY_P; ++i) {
+        int pos = caps.size() - (i / sizeof(unsigned long));
+        if (pos < 0)
+            break;
+        size_t bit = i % sizeof(unsigned long);
+        if ((caps[pos] >> bit) & 1)
+            ++count;
+    }
+    return (count == KEY_P - KEY_Q);
+}
+
+static bool isKeyboardAvailable()
+{
+    using namespace cor::udev;
+    Root udev;
+    if (!udev)
+        return false;
+
+    Enumerate input(udev);
+    if (!input)
+        return false;
+
+    input.subsystem_add("input");
+    ListEntry devs(input);
+
+    bool is_kbd_found = false;
+    auto find_kbd = [&is_kbd_found, &udev](ListEntry const &e) -> bool {
+        Device d(udev, e.path());
+        is_kbd_found = isKeyboardDevice(d);
+        return !is_kbd_found;
+    };
+    devs.for_each(find_kbd);
+    return is_kbd_found;
+}
+
+KeyboardGeneric::KeyboardGeneric()
+{
+    props[keyboard_is_present] = [&]() {
+        emitChanged(keyboard_is_present, is_kbd_available);
+    };
+    props[keyboard_is_open] = [&]() {
+        emitChanged(keyboard_is_open, is_kbd_available);
+    };
+    QMetaObject::invokeMethod(this, "ready", Qt::QueuedConnection);
+}
+
+void KeyboardGeneric::setup()
+{
+    if (!is_setup) {
+        is_kbd_available = isKeyboardAvailable();
+        is_setup = true;
+    }
+}
+
+void KeyboardGeneric::emitChanged(QString const &name, QVariant const &value)
+{
+    emit valueChanged(name, value);
+}
+
+/// Implementation of the IPropertyProvider::subscribe.
+void KeyboardGeneric::subscribe(QSet<QString> keys)
+{
+    setup();
+    foreach(QString const &k, keys) {
+        if (props.contains(k))
+            props[k]();
+    }
+}
+
+/// Implementation of the IPropertyProvider::unsubscribe.
+void KeyboardGeneric::unsubscribe(QSet<QString>)
+{
+}
+
+void KeyboardGeneric::blockUntilReady()
+{
+    emit ready();
+}
+
+void KeyboardGeneric::blockUntilSubscribed(const QString &)
+{
+}
+
+} // namespace
--- meego/keyboard-generic/plugin.hpp
+++ meego/keyboard-generic/plugin.hpp
@@ -0,0 +1,67 @@
+#ifndef _CONTEXTKIT_PLUGIN_KEYBOARD_GENERIC_HPP_
+#define _CONTEXTKIT_PLUGIN_KEYBOARD_GENERIC_HPP_
+/*
+ * Generic keyboard properties provider
+ *
+ * Copyright (C) 2012 Jolla Ltd.
+ * Contact: Denis Zalevskiy <[email protected]>
+ *
+ * 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
+ *
+ * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+ */
+
+#include <iproviderplugin.h>
+
+#include <functional>
+
+#include <QObject>
+#include <QMap>
+#include <QSet>
+
+using ContextSubscriber::IProviderPlugin;
+
+extern "C" {
+    IProviderPlugin* pluginFactory(const QString&);
+}
+
+namespace ContextKitNemo
+{
+
+class KeyboardGeneric : public IProviderPlugin
+{
+    Q_OBJECT;
+public:
+    KeyboardGeneric();
+    virtual ~KeyboardGeneric() {}
+
+    virtual void subscribe(QSet<QString>);
+    virtual void unsubscribe(QSet<QString>);
+    virtual void blockUntilReady();
+    virtual void blockUntilSubscribed(const QString&);
+
+private:
+    void setup();
+    void emitChanged(QString const &, QVariant const &);
+
+    QMap<QString, std::function<void ()> > props;
+
+    bool is_setup;
+    bool is_kbd_available;
+};
+
+}
+
+#endif //_CONTEXTKIT_PLUGIN_KEYBOARD_GENERIC_HPP_



Reply via email to