Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge with master
  • Loading branch information
bzeller committed Oct 19, 2013
2 parents 0d2008b + ae3346f commit 691a8bf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
20 changes: 14 additions & 6 deletions src/notifications/notificationfeedbackplayer.cpp
Expand Up @@ -15,6 +15,10 @@

#include <NgfClient>
#include <QWaylandSurface>
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusPendingCall>
#include <mce/dbus-names.h>
#include "lipstickcompositor.h"
#include "notificationmanager.h"
#include "notificationpreviewpresenter.h"
Expand Down Expand Up @@ -51,13 +55,17 @@ void NotificationFeedbackPlayer::addNotification(uint id)
{
LipstickNotification *notification = NotificationManager::instance()->notification(id);

if (notification != 0) {
if (notification != 0 && !idToEventId.contains(notification) && isEnabled(notification)) {
// Ask mce to turn the screen on if requested
if (notification->hints().value(NotificationManager::HINT_DISPLAY_ON).toBool()) {
QDBusMessage msg = QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_DISPLAY_ON_REQ);
QDBusConnection::systemBus().asyncCall(msg);
}

// Play the feedback related to the notification if any
if (!idToEventId.contains(notification) && isEnabled(notification)) {
QString feedback = notification->hints().value(NotificationManager::HINT_FEEDBACK).toString();
if (!feedback.isEmpty()) {
idToEventId.insert(notification, ngfClient->play(feedback, QMap<QString, QVariant>()));
}
QString feedback = notification->hints().value(NotificationManager::HINT_FEEDBACK).toString();
if (!feedback.isEmpty()) {
idToEventId.insert(notification, ngfClient->play(feedback, QMap<QString, QVariant>()));
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/notifications/notificationmanager.cpp
Expand Up @@ -39,8 +39,8 @@ static const char *CATEGORY_DEFINITION_FILE_DIRECTORY = "/usr/share/lipstick/not
//! The number configuration files to load into the event type store.
static const uint MAX_CATEGORY_DEFINITION_FILES = 100;

//! Path of the configuration directory relative to the home directory
static const char *CONFIG_PATH = "/.config/lipstick";
//! Path of the privileged storage directory relative to the home directory
static const char *PRIVILEGED_DATA_PATH= "/.local/share/system/privileged";

//! Minimum amount of disk space needed for the notification database in kilobytes
static const uint MINIMUM_FREE_SPACE_NEEDED_IN_KB = 1024;
Expand All @@ -65,6 +65,7 @@ const char *NotificationManager::HINT_USER_REMOVABLE = "x-nemo-user-removable";
const char *NotificationManager::HINT_USER_CLOSEABLE = "x-nemo-user-closeable";
const char *NotificationManager::HINT_FEEDBACK = "x-nemo-feedback";
const char *NotificationManager::HINT_HIDDEN = "x-nemo-hidden";
const char *NotificationManager::HINT_DISPLAY_ON = "x-nemo-display-on";

NotificationManager *NotificationManager::instance_ = 0;

Expand Down Expand Up @@ -286,15 +287,15 @@ void NotificationManager::restoreNotifications()

bool NotificationManager::connectToDatabase()
{
QString configPath = QDir::homePath() + QString(CONFIG_PATH);
if (!QDir::root().exists(configPath)) {
QDir::root().mkpath(configPath);
QString databasePath = QDir::homePath() + QString(PRIVILEGED_DATA_PATH) + QDir::separator() + "Notifications";
if (!QDir::root().exists(databasePath)) {
QDir::root().mkpath(databasePath);
}
QString databaseName = databasePath + "/notifications.db";

QString databaseName = configPath + "/notifications.db";
*database = QSqlDatabase::addDatabase("QSQLITE", metaObject()->className());
database->setDatabaseName(databaseName);
bool success = checkForDiskSpace(configPath, MINIMUM_FREE_SPACE_NEEDED_IN_KB);
bool success = checkForDiskSpace(databasePath, MINIMUM_FREE_SPACE_NEEDED_IN_KB);
if (success) {
success = database->open();
if (!success) {
Expand Down
3 changes: 3 additions & 0 deletions src/notifications/notificationmanager.h
Expand Up @@ -100,6 +100,9 @@ class LIPSTICK_EXPORT NotificationManager : public QObject
//! Nemo hint: Whether the notification is hidden.
static const char *HINT_HIDDEN;

//! Nemo hint: Whether to turn the screen on when displaying preview
static const char *HINT_DISPLAY_ON;

//! Notifation closing reasons used in the NotificationClosed signal
enum NotificationClosedReason {
//! The notification expired.
Expand Down
Expand Up @@ -32,6 +32,7 @@ const char *NotificationManager::HINT_PREVIEW_BODY = "x-nemo-preview-body";
const char *NotificationManager::HINT_PREVIEW_SUMMARY = "x-nemo-preview-summary";
const char *NotificationManager::HINT_FEEDBACK = "x-nemo-feedback";
const char *NotificationManager::HINT_USER_REMOVABLE = "x-nemo-user-removable";
const char *NotificationManager::HINT_DISPLAY_ON = "x-nemo-display-on";

NotificationManager::NotificationManager(QObject *parent) : QObject(parent)
{
Expand Down

0 comments on commit 691a8bf

Please sign in to comment.