aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--debian/control1
-rw-r--r--include/notifications/haptic.h57
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/haptic.cpp92
-rw-r--r--src/notifications.cpp2
-rw-r--r--src/snap.cpp8
7 files changed, 160 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9b4987e..3bc7e81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,8 @@ pkg_check_modules (SERVICE_DEPS REQUIRED
gstreamer-1.0>=1.2
libnotify>=0.7.6
url-dispatcher-1>=1
- properties-cpp>=0.0.1)
+ properties-cpp>=0.0.1
+ ubuntu-platform-api>=2.2.0)
include_directories (SYSTEM ${SERVICE_DEPS_INCLUDE_DIRS})
CHECK_INCLUDE_FILE(ubuntu/hardware/alarm.h HAVE_UBUNTU_HW_ALARM_H)
diff --git a/debian/control b/debian/control
index 77e9241..dab9096 100644
--- a/debian/control
+++ b/debian/control
@@ -21,6 +21,7 @@ Build-Depends: cmake,
libproperties-cpp-dev,
libubuntu-platform-hardware-api-headers [armhf i386 amd64],
libubuntu-platform-hardware-api-dev [armhf i386 amd64],
+ libubuntu-application-api-dev [armhf i386 amd64],
libdbustest1-dev,
locales,
Standards-Version: 3.9.3
diff --git a/include/notifications/haptic.h b/include/notifications/haptic.h
new file mode 100644
index 0000000..3036485
--- /dev/null
+++ b/include/notifications/haptic.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2014 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#ifndef UNITY_INDICATOR_NOTIFICATIONS_HAPTIC_H
+#define UNITY_INDICATOR_NOTIFICATIONS_HAPTIC_H
+
+#include <memory>
+
+namespace unity {
+namespace indicator {
+namespace notifications {
+
+/***
+****
+***/
+
+/**
+ * A class that forces the screen display on and inhibits sleep
+ */
+class Haptic
+{
+public:
+ enum Mode { VIBRATE_DEFAULT };
+
+ Haptic(const Mode& mode = VIBRATE_DEFAULT);
+ ~Haptic();
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+/***
+****
+***/
+
+} // namespace notifications
+} // namespace indicator
+} // namespace unity
+
+#endif // UNITY_INDICATOR_NOTIFICATIONS_HAPTIC_H
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 754d537..a466a48 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,6 +20,7 @@ set (SERVICE_CXX_SOURCES
exporter.cpp
formatter.cpp
formatter-desktop.cpp
+ haptic.cpp
locations.cpp
locations-settings.cpp
menu.cpp
diff --git a/src/haptic.cpp b/src/haptic.cpp
new file mode 100644
index 0000000..c5a20df
--- /dev/null
+++ b/src/haptic.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2014 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#include <notifications/haptic.h>
+
+#include <ubuntu/application/sensors/haptic.h>
+
+#include <glib.h>
+
+namespace unity {
+namespace indicator {
+namespace notifications {
+
+/***
+****
+***/
+
+class Haptic::Impl
+{
+public:
+
+ Impl(const Mode& mode):
+ m_mode(mode),
+ m_sensor(ua_sensors_haptic_new())
+ {
+ if (m_sensor == nullptr)
+ g_warning ("Haptic device unavailable");
+ else
+ m_tag = g_timeout_add_seconds (1, on_timeout, this);
+ }
+
+ ~Impl()
+ {
+ if (m_tag)
+ g_source_remove(m_tag);
+ }
+
+private:
+
+ static gboolean on_timeout (gpointer gself)
+ {
+ static_cast<Impl*>(gself)->vibrate_now();
+ return G_SOURCE_CONTINUE;
+ }
+
+ void vibrate_now()
+ {
+ const uint32_t msec = 1500;
+ ua_sensors_haptic_vibrate_once (m_sensor, msec);
+ }
+
+ const Mode m_mode;
+ UASensorsHaptic * m_sensor = nullptr;
+ guint m_tag = 0;
+};
+
+/***
+****
+***/
+
+Haptic::Haptic(const Mode& mode):
+ impl(new Impl (mode))
+{
+}
+
+Haptic::~Haptic()
+{
+}
+
+/***
+****
+***/
+
+} // namespace datetime
+} // namespace indicator
+} // namespace unity
diff --git a/src/notifications.cpp b/src/notifications.cpp
index da7351b..c66f634 100644
--- a/src/notifications.cpp
+++ b/src/notifications.cpp
@@ -327,7 +327,7 @@ Engine::~Engine()
bool
Engine::supports_actions() const
{
- return impl->supports_actions();
+ return true; //impl->supports_actions();
}
int
diff --git a/src/snap.cpp b/src/snap.cpp
index 0eb176c..f3e0f20 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -20,6 +20,7 @@
#include <datetime/snap.h>
#include <notifications/awake.h>
+#include <notifications/haptic.h>
#include <notifications/sound.h>
#include <gst/gst.h>
@@ -76,6 +77,9 @@ public:
const bool loop = m_engine->supports_actions();
auto sound = std::make_shared<uin::Sound>(uri, volume, loop);
+ // create the haptic feedback...
+ auto haptic = std::make_shared<uin::Haptic>();
+
// show a notification...
const auto minutes = std::chrono::minutes(m_settings->alarm_duration.get());
const bool interactive = m_engine->supports_actions();
@@ -94,10 +98,10 @@ public:
b.add_action ("dismiss", _("Dismiss"));
}
- // add the 'sound' and 'awake' objects to the capture so that
+ // add 'sound', 'haptic', and 'awake' objects to the capture so
// they stay alive until the closed callback is called; i.e.,
// for the lifespan of the notficiation
- b.set_closed_callback([appointment, show, dismiss, sound, awake]
+ b.set_closed_callback([appointment, show, dismiss, sound, awake, haptic]
(const std::string& action){
if (action == "show")
show(appointment);