aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-08-08 20:52:31 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-08-08 20:52:31 +0000
commit0777142ba348c212f57af039c6f7b2ae15d5058f (patch)
treec4998c28ec72c215ccb8bff40ef5851e826358ac /include
parent23b0a5d6d97b8e36443a2a719b879f99975ef972 (diff)
parent9cc6380c1cb0c4e96a893a1b9d2720d2ed3181bd (diff)
downloadayatana-indicator-datetime-0777142ba348c212f57af039c6f7b2ae15d5058f.tar.gz
ayatana-indicator-datetime-0777142ba348c212f57af039c6f7b2ae15d5058f.tar.bz2
ayatana-indicator-datetime-0777142ba348c212f57af039c6f7b2ae15d5058f.zip
Add haptic feedback support for alarms. Fixes: 1350017
Approved by: Antti Kaijanmäki, PS Jenkins bot, Nekhelesh Ramananthan
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt1
-rw-r--r--include/datetime/dbus-shared.h14
-rw-r--r--include/datetime/settings-live.h1
-rw-r--r--include/datetime/settings-shared.h1
-rw-r--r--include/datetime/settings.h1
-rw-r--r--include/datetime/snap.h14
-rw-r--r--include/notifications/CMakeLists.txt0
-rw-r--r--include/notifications/awake.h55
-rw-r--r--include/notifications/dbus-shared.h36
-rw-r--r--include/notifications/haptic.h60
-rw-r--r--include/notifications/notifications.h116
-rw-r--r--include/notifications/sound.h60
12 files changed, 339 insertions, 20 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 486e9c7..15a7c33 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -1 +1,2 @@
add_subdirectory(datetime)
+add_subdirectory(notifications)
diff --git a/include/datetime/dbus-shared.h b/include/datetime/dbus-shared.h
index 4b71ce5..db10c1d 100644
--- a/include/datetime/dbus-shared.h
+++ b/include/datetime/dbus-shared.h
@@ -18,18 +18,10 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
-#ifndef _DBUS_SHARED_H_
-#define _DBUS_SHARED_H_
+#ifndef _INDICATOR_DATETIME_DBUS_SHARED_H_
+#define _INDICATOR_DATETIME_DBUS_SHARED_H_
#define BUS_DATETIME_NAME "com.canonical.indicator.datetime"
#define BUS_DATETIME_PATH "/com/canonical/indicator/datetime"
-#define BUS_SCREEN_NAME "com.canonical.Unity.Screen"
-#define BUS_SCREEN_PATH "/com/canonical/Unity/Screen"
-#define BUS_SCREEN_INTERFACE "com.canonical.Unity.Screen"
-
-#define BUS_POWERD_NAME "com.canonical.powerd"
-#define BUS_POWERD_PATH "/com/canonical/powerd"
-#define BUS_POWERD_INTERFACE "com.canonical.powerd"
-
-#endif /* _DBUS_SHARED_H_ */
+#endif /* _INDICATOR_DATETIME_DBUS_SHARED_H_ */
diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h
index 4db2d40..4850e69 100644
--- a/include/datetime/settings-live.h
+++ b/include/datetime/settings-live.h
@@ -58,6 +58,7 @@ private:
void update_alarm_sound();
void update_alarm_volume();
void update_alarm_duration();
+ void update_alarm_haptic();
GSettings* m_settings;
diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h
index 23d2e1c..a211821 100644
--- a/include/datetime/settings-shared.h
+++ b/include/datetime/settings-shared.h
@@ -48,5 +48,6 @@ TimeFormatMode;
#define SETTINGS_ALARM_SOUND_S "alarm-default-sound"
#define SETTINGS_ALARM_VOLUME_S "alarm-default-volume"
#define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes"
+#define SETTINGS_ALARM_HAPTIC_S "alarm-haptic-feedback"
#endif // INDICATOR_DATETIME_SETTINGS_SHARED
diff --git a/include/datetime/settings.h b/include/datetime/settings.h
index e5f885e..c6fe13b 100644
--- a/include/datetime/settings.h
+++ b/include/datetime/settings.h
@@ -57,6 +57,7 @@ public:
core::Property<TimeFormatMode> time_format_mode;
core::Property<std::string> timezone_name;
core::Property<std::string> alarm_sound;
+ core::Property<std::string> alarm_haptic;
core::Property<unsigned int> alarm_volume;
core::Property<unsigned int> alarm_duration;
};
diff --git a/include/datetime/snap.h b/include/datetime/snap.h
index 1c90496..ef5c868 100644
--- a/include/datetime/snap.h
+++ b/include/datetime/snap.h
@@ -21,12 +21,12 @@
#define INDICATOR_DATETIME_SNAP_H
#include <datetime/appointment.h>
-#include <datetime/clock.h>
#include <datetime/settings.h>
+#include <notifications/notifications.h>
+
#include <functional>
#include <memory>
-#include <set>
namespace unity {
namespace indicator {
@@ -38,7 +38,7 @@ namespace datetime {
class Snap
{
public:
- Snap(const std::shared_ptr<Clock>& clock,
+ Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine,
const std::shared_ptr<const Settings>& settings);
virtual ~Snap();
@@ -48,12 +48,8 @@ public:
appointment_func dismiss);
private:
- const std::shared_ptr<Clock> m_clock;
- const std::shared_ptr<const Settings> m_settings;
-
- class Popup;
- friend class Popup;
- std::set<Popup*> m_pending;
+ class Impl;
+ std::unique_ptr<Impl> impl;
};
} // namespace datetime
diff --git a/include/notifications/CMakeLists.txt b/include/notifications/CMakeLists.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/notifications/CMakeLists.txt
diff --git a/include/notifications/awake.h b/include/notifications/awake.h
new file mode 100644
index 0000000..fd812c1
--- /dev/null
+++ b/include/notifications/awake.h
@@ -0,0 +1,55 @@
+/*
+ * 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_AWAKE_H
+#define UNITY_INDICATOR_NOTIFICATIONS_AWAKE_H
+
+#include <memory>
+
+namespace unity {
+namespace indicator {
+namespace notifications {
+
+/***
+****
+***/
+
+/**
+ * A class that forces the screen display on and inhibits sleep
+ */
+class Awake
+{
+public:
+ Awake(const std::string& app_name);
+ ~Awake();
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+/***
+****
+***/
+
+} // namespace notifications
+} // namespace indicator
+} // namespace unity
+
+#endif // UNITY_INDICATOR_NOTIFICATIONS_AWAKE_H
diff --git a/include/notifications/dbus-shared.h b/include/notifications/dbus-shared.h
new file mode 100644
index 0000000..af714e7
--- /dev/null
+++ b/include/notifications/dbus-shared.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2013 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:
+ * Ted Gould <ted@canonical.com>
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#ifndef UNITY_INDICATOR_NOTIFICATIONS_DBUS_SHARED_H
+#define UNITY_INDICATOR_NOTIFICATIONS_DBUS_SHARED_H
+
+#define BUS_SCREEN_NAME "com.canonical.Unity.Screen"
+#define BUS_SCREEN_PATH "/com/canonical/Unity/Screen"
+#define BUS_SCREEN_INTERFACE "com.canonical.Unity.Screen"
+
+#define BUS_POWERD_NAME "com.canonical.powerd"
+#define BUS_POWERD_PATH "/com/canonical/powerd"
+#define BUS_POWERD_INTERFACE "com.canonical.powerd"
+
+#define BUS_HAPTIC_NAME "com.canonical.usensord"
+#define BUS_HAPTIC_PATH "/com/canonical/usensord/haptic"
+#define BUS_HAPTIC_INTERFACE "com.canonical.usensord.haptic"
+
+#endif /* INDICATOR_NOTIFICATIONS_DBUS_SHARED_H */
diff --git a/include/notifications/haptic.h b/include/notifications/haptic.h
new file mode 100644
index 0000000..bfb5679
--- /dev/null
+++ b/include/notifications/haptic.h
@@ -0,0 +1,60 @@
+/*
+ * 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 {
+
+/***
+****
+***/
+
+/**
+ * Tries to emit haptic feedback to match the user-specified mode.
+ */
+class Haptic
+{
+public:
+ enum Mode
+ {
+ MODE_PULSE
+ };
+
+ Haptic(const Mode& mode = MODE_PULSE);
+ ~Haptic();
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+/***
+****
+***/
+
+} // namespace notifications
+} // namespace indicator
+} // namespace unity
+
+#endif // UNITY_INDICATOR_NOTIFICATIONS_HAPTIC_H
diff --git a/include/notifications/notifications.h b/include/notifications/notifications.h
new file mode 100644
index 0000000..260b466
--- /dev/null
+++ b/include/notifications/notifications.h
@@ -0,0 +1,116 @@
+/*
+ * 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_NOTIFICATIONS_H
+#define UNITY_INDICATOR_NOTIFICATIONS_NOTIFICATIONS_H
+
+#include <chrono>
+#include <functional>
+#include <memory>
+#include <string>
+
+namespace unity {
+namespace indicator {
+namespace notifications {
+
+class Engine;
+
+/**
+ * Helper class for showing notifications.
+ *
+ * Populate the builder, then pass it to Engine::show().
+ *
+ * @see Engine::show(Builder)
+ */
+class Builder
+{
+public:
+ Builder();
+ ~Builder();
+
+ void set_title (const std::string& title);
+
+ void set_body (const std::string& body);
+
+ void set_icon_name (const std::string& icon_name);
+
+ /* Set an interval, after which the notification will automatically
+ be closed. If not set, the notification server's default timeout
+ is used. */
+ void set_timeout (const std::chrono::seconds& duration);
+
+ /* Add a notification hint.
+ These keys may be dependent on the notification server. */
+ void add_hint (const std::string& name);
+ static constexpr char const * HINT_SNAP {"x-canonical-snap-decisions"};
+ static constexpr char const * HINT_TINT {"x-canonical-private-button-tint"};
+ static constexpr char const * HINT_NONSHAPEDICON {"x-canonical-non-shaped-icon"};
+
+ /* Add an action button.
+ This may fail if the Engine doesn't support actions.
+ @see Engine::supports_actions() */
+ void add_action (const std::string& action, const std::string& label);
+
+ /** Sets the closed callback. This will be called exactly once. */
+ void set_closed_callback (std::function<void(const std::string& action)>);
+
+private:
+ friend class Engine;
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+/**
+ * Manages Notifications and the connection to the notification server.
+ *
+ * When this class is destroyed, any remaining notifications it created
+ * will be closed and their closed() callbacks will be invoked.
+ */
+class Engine
+{
+public:
+ Engine(const std::string& app_name);
+ ~Engine();
+
+ /** @see Builder::set_action() */
+ bool supports_actions() const;
+
+ /** Show a notification.
+ @return zero on failure, or a key that can be passed to close() */
+ int show(const Builder& builder);
+
+ /** Close a notification.
+ @param key the int returned by show() */
+ void close(int key);
+
+ /** Close all remaining notifications. */
+ void close_all();
+
+ const std::string& app_name() const;
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+} // namespace notifications
+} // namespace indicator
+} // namespace unity
+
+#endif // UNITY_INDICATOR_NOTIFICATIONS_NOTIFICATIONS_H
diff --git a/include/notifications/sound.h b/include/notifications/sound.h
new file mode 100644
index 0000000..f5f549c
--- /dev/null
+++ b/include/notifications/sound.h
@@ -0,0 +1,60 @@
+/*
+ * 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_SOUND_H
+#define UNITY_INDICATOR_NOTIFICATIONS_SOUND_H
+
+#include <memory>
+#include <string>
+
+namespace unity {
+namespace indicator {
+namespace notifications {
+
+/***
+****
+***/
+
+/**
+ * Plays a sound, possibly looping.
+ *
+ * @param uri the file to play
+ * @param volume the volume at which to play the sound, [0..100]
+ * @param loop if true, loop the sound for the lifespan of the object
+ */
+class Sound
+{
+public:
+ Sound(const std::string& uri, unsigned int volume, bool loop);
+ ~Sound();
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+/***
+****
+***/
+
+} // namespace notifications
+} // namespace indicator
+} // namespace unity
+
+#endif // UNITY_INDICATOR_NOTIFICATIONS_SOUND_H