コード例 #1
0
ファイル: batterynotifier.cpp プロジェクト: kaltsi/lipstick
void BatteryNotifier::applyChargerType(QBatteryInfo::ChargerType type)
{
    switch(type) {
    case QBatteryInfo::UnknownCharger:
        /*
         * After the user plugs out the charger from the device, this system
         * banner is displayed to remind the users to unplug charger from
         * the power supply for conserving energy.  Remove charger
         * notification should not be shown in case if USB cable is used for
         * charging the device.
         */
        if (chargerType == QBatteryInfo::WallCharger) {
            removeNotification(QStringList() << "x-nemo.battery" << "x-nemo.battery.chargingcomplete");
            sendNotification(NotificationRemoveCharger);
        }

        if (chargerType != QBatteryInfo::UnknownCharger && chargerType != QBatteryInfo::USBCharger && batteryInfo->batteryStatus(0) == QBatteryInfo::BatteryLow && batteryInfo->chargingState(0) != QBatteryInfo::Charging) {
            // A charger was connected but is no longer connected and the battery is low, so start low battery notifier
            startLowBatteryNotifier();
        }
        break;

    default:
        break;
    }

    chargerType = type;
}
コード例 #2
0
ファイル: batterynotifier.cpp プロジェクト: AOSC-Dev/lipstick
void BatteryNotifier::applyBatteryStatus(int, QBatteryInfo::BatteryStatus status)
{
    switch(status) {
    case QBatteryInfo::BatteryFull:
        stopLowBatteryNotifier();
        removeNotification(QStringList() << "x-nemo.battery");
        if (batteryInfo->chargingState(0) == QBatteryInfo::Charging || batteryInfo->chargingState(0) == QBatteryInfo::Full) {
            sendNotification(NotificationChargingComplete);
        }
        break;

    case QBatteryInfo::BatteryOk:
        stopLowBatteryNotifier();
        break;

    case QBatteryInfo::BatteryLow:
        if (batteryInfo->chargingState(0) != QBatteryInfo::Charging) {
            // The low battery notifications should be sent only if the battery is not charging
            startLowBatteryNotifier();
        }
        break;

    case QBatteryInfo::BatteryEmpty:
        sendNotification(NotificationRechargeBattery);
        break;

    default:
        break;
    }
}
コード例 #3
0
void NotificationLayout::removeNotificationUser()
{
    Notification *n = qobject_cast<Notification*>(sender());
    if (!n)
    {
        qDebug() << "Oooook! USERCANCEL Expecting instance of notification, got:" << sender();
        return;
    }

    removeNotification(m_notifications.key(n), 2);
}
コード例 #4
0
void NotificationLayout::removeNotificationTimeout()
{
    Notification *n = qobject_cast<Notification*>(sender());
    if (!n)
    {
        qDebug() << "Oooook! TIMEOUT Expecting instance of notification, got:" << sender();
        return;
    }

    removeNotification(m_notifications.key(n), 1);
}
void Ut_DBusInterfaceNotificationSink::init()
{
    qDBusConnectionConnectService.clear();
    qDBusConnectionConnectPath.clear();
    qDBusConnectionConnectInterface.clear();
    qDBusConnectionConnectName.clear();
    qDBusConnectionConnectReceiver.clear();
    qDBusConnectionConnectSlot.clear();

    manager = new NotificationManager;
    sink = new DBusInterfaceNotificationSink(manager);

    connect(this, SIGNAL(addNotification(Notification)), sink, SLOT(addNotification(Notification)));
    connect(this, SIGNAL(addGroup(uint,NotificationParameters)), sink, SLOT(addGroup(uint,NotificationParameters)));
    connect(this, SIGNAL(removeNotification(uint)), sink, SLOT(removeNotification(uint)));
    connect(this, SIGNAL(removeGroup(uint)), sink, SLOT(removeGroup(uint)));
    gNotificationManagerStub->stubReset();

    gNotificationGroupStub->stubReset();
    gNotificationGroupStub->stubSetReturnValue<const NotificationParameters&>("parameters", fakeParams);
}
void Ut_DBusInterfaceNotificationSink::testNothingCalledWhenNothingRegistered()
{
    Notification n;
    NotificationParameters np;

    emit addNotification(n);
    emit addGroup(0, np);
    emit removeNotification(0);
    emit removeGroup(0);

    QCOMPARE(gAddNotificationProxies.count(), 0);
    QCOMPARE(gAddGroupProxies.count(), 0);
    QCOMPARE(gRemoveNotificationProxies.count(), 0);
    QCOMPARE(gRemoveGroupProxies.count(), 0);
}
コード例 #7
0
ファイル: notifyd.cpp プロジェクト: Odeskguru/razor-qt
Notifyd::Notifyd(QObject* parent)
    : QObject(parent),
      mId(0)
{
    m_area = new NotificationArea();
    ReloadSettings();

    connect(this, SIGNAL(notificationAdded(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)),
            m_area->layout(), SLOT(addNotification(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)));
    connect(this, SIGNAL(notificationClosed(uint, uint)),
            m_area->layout(), SLOT(removeNotification(uint, uint)));
    // feedback for original caller
    connect(m_area->layout(), SIGNAL(notificationClosed(uint,uint)),
            this, SIGNAL(NotificationClosed(uint,uint)));
    connect(m_area->layout(), SIGNAL(actionInvoked(uint, QString)),
            this, SIGNAL(ActionInvoked(uint,QString)));

}
コード例 #8
0
void BatteryNotifier::batteryChargerEvent(MeeGo::QmBattery::ChargerType type)
{
    switch(type) {
    case MeeGo::QmBattery::None:
        /*
         * After the user plugs out the charger from the device, this system
         * banner is displayed to remind the users to unplug charger from
         * the power supply for conserving energy.  Remove charger
         * notification should not be shown in case if USB cable is used for
         * charging the device.
         */
        if (chargerType == MeeGo::QmBattery::Wall) {
            removeNotification(QStringList() << "x-nemo.battery" << "x-nemo.battery.chargingcomplete");
            sendNotification(NotificationRemoveCharger);
        }

        if (chargerType != MeeGo::QmBattery::None && chargerType != MeeGo::QmBattery::USB_100mA && qmBattery->getBatteryState() == MeeGo::QmBattery::StateLow && qmBattery->getChargingState() != MeeGo::QmBattery::StateCharging) {
            // A charger was connected but is no longer connected and the battery is low, so start low battery notifier
            startLowBatteryNotifier();
        }
        break;

    case MeeGo::QmBattery::Wall:
        // Wall charger
        break;

    case MeeGo::QmBattery::USB_500mA:
        // USB with 500mA output
        break;

    case MeeGo::QmBattery::USB_100mA:
        // USB with 100mA output
        break;

    default:
        break;
    }

    chargerType = type;
}
void Ut_DBusInterfaceNotificationSink::testProxyCalledWhenServiceRegistered()
{
    Notification n;
    NotificationParameters np;

    sink->registerSink("service1", "path");
    QCOMPARE(gNewSinkProxies.count(), 1);

    emit addNotification(n);
    emit addGroup(0, np);
    emit removeNotification(0);
    emit removeGroup(0);

    QCOMPARE(gAddNotificationProxies.count(), 1);
    QCOMPARE(gAddNotificationProxies.at(0), gNewSinkProxies.at(0));
    QCOMPARE(gAddGroupProxies.count(), 1);
    QCOMPARE(gAddGroupProxies.at(0), gNewSinkProxies.at(0));
    QCOMPARE(gRemoveNotificationProxies.count(), 1);
    QCOMPARE(gRemoveNotificationProxies.at(0), gNewSinkProxies.at(0));
    QCOMPARE(gRemoveGroupProxies.count(), 1);
    QCOMPARE(gRemoveGroupProxies.at(0), gNewSinkProxies.at(0));
}
コード例 #10
0
void Ut_NotificationListModel::testSignalConnections()
{
    NotificationListModel model;
    QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), &model, SLOT(updateNotification(uint))), true);
    QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), &model, SLOT(removeNotification(uint))), true);
    QCOMPARE(disconnect(&model, SIGNAL(clearRequested()), NotificationManager::instance(), SLOT(removeUserRemovableNotifications())), true);
}
コード例 #11
0
NotificationListModel::NotificationListModel(QObject *parent) :
    QObjectListModel(parent)
{
    connect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), this, SLOT(updateNotification(uint)));
    connect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), this, SLOT(removeNotification(uint)));
    connect(this, SIGNAL(clearRequested()), NotificationManager::instance(), SLOT(removeUserRemovableNotifications()));

    QTimer::singleShot(0, this, SLOT(init()));
}
コード例 #12
0
void Ut_NotificationPreviewPresenter::testSignalConnections()
{
    NotificationPreviewPresenter presenter;
    QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), &presenter, SLOT(updateNotification(uint))), true);
    QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), &presenter, SLOT(removeNotification(uint))), true);
}
コード例 #13
0
void Ut_Sysuid::cleanup()
{
    delete sysuid;
    gStatusIndicatorMenuBusinessLogicStub->stubReset();
}

void Ut_Sysuid::testInitialization()
{
    QCOMPARE(gNotificationManagerStub->stubCallCount("initializeStore"), 1);
}

void Ut_Sysuid::testSignalConnections()
{
    QVERIFY(disconnect(sysuid->statusIndicatorMenuBusinessLogic, SIGNAL(statusIndicatorMenuVisibilityChanged(bool)), sysuid, SLOT(updateCompositorNotificationSinkEnabledStatus())));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationUpdated (const Notification &)), sysuid->mCompositorNotificationSink, SLOT(addNotification (const Notification &))));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRemoved(uint)), sysuid->mCompositorNotificationSink, SLOT(removeNotification(uint))));
    QVERIFY(disconnect(sysuid->mCompositorNotificationSink, SIGNAL(notificationRemovalRequested(uint)), sysuid->notificationManager, SLOT(removeNotification(uint))));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationUpdated (const Notification &)), sysuid->ngfNotificationSink, SLOT(addNotification (const Notification &))));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRemoved(uint)), sysuid->ngfNotificationSink, SLOT(removeNotification(uint))));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationUpdated(const Notification &)), sysuid->notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &))));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRemoved(uint)), sysuid->notificationStatusIndicatorSink_, SLOT(removeNotification(uint))));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRestored(const Notification &)), sysuid->notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &))));
    QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(groupUpdated(uint, const NotificationParameters &)), sysuid->notificationStatusIndicatorSink_, SLOT(addGroup(uint, const NotificationParameters &))));
    QVERIFY(disconnect(sysuid->screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), sysuid, SLOT(updateCompositorNotificationSinkEnabledStatus())));
    QVERIFY(disconnect(sysuid->screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), sysuid->mCompositorNotificationSink, SLOT(setTouchScreenLockActive(bool))));
    QVERIFY(disconnect(sysuid->screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), sysuid->batteryBusinessLogic, SLOT(setTouchScreenLockActive(bool))));
    QVERIFY(disconnect(sysuid->usbUi, SIGNAL(dialogShown()), sysuid->screenLockBusinessLogic, SLOT(unlockScreen())));

#ifdef HAVE_QMSYSTEM
    QVERIFY(disconnect(&sysuid->qmLocks, SIGNAL(stateChanged (MeeGo::QmLocks::Lock, MeeGo::QmLocks::State)), sysuid, SLOT(updateCompositorNotificationSinkEnabledStatus())));
#endif
コード例 #14
0
Sysuid::Sysuid(QObject* parent) : QObject(parent)
{
    instance_ = this;

    // Load translations of System-UI
    loadTranslations();

    // D-Bus registration
    QDBusConnection bus = QDBusConnection::sessionBus();
    if (!bus.registerService(SYSTEMUI_DBUS_SERVICE)) {
        qCritical("Unable to register system-ui D-Bus service %s: %s", SYSTEMUI_DBUS_SERVICE, bus.lastError().message().toUtf8().constData());
        abort();
    }
    if (!bus.registerObject(SYSTEMUI_DBUS_PATH, instance())) {
        qCritical("Unable to register system-ui object at path %s: %s", SYSTEMUI_DBUS_PATH, bus.lastError().message().toUtf8().constData());
        abort();
    }

    // Initialize notification system
    notificationManager = new NotificationManager(NOTIFICATION_RELAY_INTERVAL);
    mCompositorNotificationSink = new MCompositorNotificationSink;
    ngfNotificationSink = new NGFNotificationSink;
    notificationStatusIndicatorSink_ = new NotificationStatusIndicatorSink;

    // Connect the notification signals for the compositor notification sink
    connect(notificationManager, SIGNAL(notificationUpdated(const Notification &)), mCompositorNotificationSink, SLOT(addNotification(const Notification &)));
    connect(notificationManager, SIGNAL(notificationRemoved(uint)), mCompositorNotificationSink, SLOT(removeNotification(uint)));
    connect(mCompositorNotificationSink, SIGNAL(notificationRemovalRequested(uint)), notificationManager, SLOT(removeNotification(uint)));

    // Connect the notification signals for the feedback notification sink
    connect(notificationManager, SIGNAL(notificationUpdated(const Notification &)), ngfNotificationSink, SLOT(addNotification(const Notification &)));
    connect(notificationManager, SIGNAL(notificationRemoved(uint)), ngfNotificationSink, SLOT(removeNotification(uint)));

    // Connect the notification signals for the notification status indicator sink
    connect(notificationManager, SIGNAL(notificationUpdated(const Notification &)), notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &)));
    connect(notificationManager, SIGNAL(notificationRemoved(uint)), notificationStatusIndicatorSink_, SLOT(removeNotification(uint)));
    connect(notificationManager, SIGNAL(notificationRestored(const Notification &)), notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &)));
    connect(notificationManager, SIGNAL(groupUpdated(uint, const NotificationParameters &)), notificationStatusIndicatorSink_, SLOT(addGroup(uint, const NotificationParameters &)));

    // Subscribe to a context property for getting information about the video recording status
    ContextFrameworkContext context;
    useMode = QSharedPointer<ContextItem>(context.createContextItem("/com/nokia/policy/camera"));
    useMode.data()->subscribe();
    connect(useMode.data(), SIGNAL(contentsChanged()), this, SLOT(applyUseMode()));
    applyUseMode();

    // Create shut down UI
    shutdownBusinessLogic = new ShutdownBusinessLogic(this);
    new ShutdownBusinessLogicAdaptor(this, shutdownBusinessLogic);

    // Create a status area renderer for rendering the shared status area pixmap
    statusAreaRenderer = new StatusAreaRenderer(this);
    new StatusAreaRendererAdaptor(statusAreaRenderer);
    bus.registerService("com.meego.core.MStatusBar");
    bus.registerObject("/statusbar", statusAreaRenderer);

    // Create a status indicator menu
    statusIndicatorMenuBusinessLogic = new StatusIndicatorMenuBusinessLogic(this);
    connect(statusIndicatorMenuBusinessLogic, SIGNAL(statusIndicatorMenuVisibilityChanged(bool)), this, SLOT(updateCompositorNotificationSinkEnabledStatus()));
    new StatusIndicatorMenuAdaptor(statusIndicatorMenuBusinessLogic);
    bus.registerService("com.meego.core.MStatusIndicatorMenu");
    bus.registerObject("/statusindicatormenu", statusIndicatorMenuBusinessLogic);

    // Create screen lock business logic
    screenLockBusinessLogic = new ScreenLockBusinessLogic(this);
    new ScreenLockBusinessLogicAdaptor(screenLockBusinessLogic);
    connect(screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), this, SLOT(updateCompositorNotificationSinkEnabledStatus()));
    connect(screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), mCompositorNotificationSink, SLOT(setTouchScreenLockActive(bool)));

    // MCE expects the service to be registered on the system bus
    QDBusConnection systemBus = QDBusConnection::systemBus();
    if (!systemBus.registerService(SCREENLOCK_DBUS_SERVICE)) {
        qWarning("Unable to register screen lock D-Bus service %s: %s", SCREENLOCK_DBUS_SERVICE, systemBus.lastError().message().toUtf8().constData());
    }
    if (!systemBus.registerObject(SCREENLOCK_DBUS_PATH, screenLockBusinessLogic)) {
        qWarning("Unable to register screen lock object at path %s: %s", SCREENLOCK_DBUS_PATH, systemBus.lastError().message().toUtf8().constData());
    }

    // Update the enabled status of compositor notification sink based on screen and device locks
#ifdef HAVE_QMSYSTEM
    connect(&qmLocks, SIGNAL(stateChanged(MeeGo::QmLocks::Lock, MeeGo::QmLocks::State)), this, SLOT(updateCompositorNotificationSinkEnabledStatus()));
#endif
    updateCompositorNotificationSinkEnabledStatus();

    // Create an extension area for the volume extension
    volumeExtensionArea = new MApplicationExtensionArea("com.meego.core.VolumeExtensionInterface/0.20");
    volumeExtensionArea->setInProcessFilter(QRegExp("/sysuid-volume.desktop$"));
    volumeExtensionArea->setOutOfProcessFilter(QRegExp("$^"));
    volumeExtensionArea->init();

    // Initialize notifications store after all the signal connections are made to the notification sinks but before any components that may send/remove notifications
    notificationManager->initializeStore();

    // Create components that may create or remove notifications
    batteryBusinessLogic = new BatteryBusinessLogic(this);
    connect(screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), batteryBusinessLogic, SLOT(setTouchScreenLockActive(bool)));

    usbUi = new UsbUi(this);

    new DiskSpaceNotifier(this);

    // Unlock the touch screen lock when displaying the USB dialog
    connect(usbUi, SIGNAL(dialogShown()), screenLockBusinessLogic, SLOT(unlockScreen()));
}
コード例 #15
0
NotificationPreviewPresenter::NotificationPreviewPresenter(QObject *parent) :
    QObject(parent),
    window(0),
    currentNotification(0),
    notificationFeedbackPlayer(new NotificationFeedbackPlayer(this)),
    locks(new MeeGo::QmLocks(this)),
    displayState(new MeeGo::QmDisplayState(this))
{
    connect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), this, SLOT(updateNotification(uint)));
    connect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), this, SLOT(removeNotification(uint)));
    connect(this, SIGNAL(notificationPresented(uint)), notificationFeedbackPlayer, SLOT(addNotification(uint)));

    QTimer::singleShot(0, this, SLOT(createWindowIfNecessary()));
}
コード例 #16
0
ファイル: handler_packettype.c プロジェクト: Oblify/Server
// type number 13
void handler_SendOutput( struct Oblify *oblify )
{
	DEBUG_PRINT(("handler_SendOutput\n"));
	char *notification = NULL;
	char *notificationID = NULL;
	seperateNotification( oblify->payload , &notification , &notificationID );


	if (oblify->payloadSize > 0 && oblify->flag != 4) {
		DEBUG_PRINT(("set notificationID %s\n" , notificationID));

		oblify->type = Acknowledge;
		oblify->deviceID = deviceID;
		oblify->flag = 1 << 2;

		char *temp = (char *)malloc( sizeof(char) * strlen( notificationID ) + 3 );
		if (temp == NULL) {
			perror( "malloc temp" );
			exit( 1 );
		}

		strlcat( temp , "13;" , 4 );
		strlcat( temp , notificationID , sizeof(notificationID));

		oblify->payload = temp;
		oblify->payloadSize = (unsigned short)strlen( notificationID ) + 3;
		sendPacketFromOblify( *oblify , 35813 );

		//notifyWithGermanVoiceURL(notification , "oblify" , "state information" , localURL , notificationID);

		//notifyWithSoundURL( notification , "oblify" , "state information" , localURL , notificationID );
		//notifyWithGermanVoice(notification, "oblify", "state information",notificationID);

		if (strncmp( &lastNotificationID , notificationID , strlen( notificationID )) == 0) {

		}else {
			notifyWithBritishVoice( notification , "oblify" , "state information" , notificationID );
			lastNotificationID = *notificationID;
		}



		//notifyWithSound(notification, "oblify", "state information",notificationID);
		//notifyWithoutSound(notification, "oblify", "state information",notificationID);
		//notifyWithSound(notification, "oblify", "state information",notificationID);

	}else if (oblify->flag & 4) {
		removeNotification( notificationID );
		DEBUG_PRINT(("remove notificationID %s\n" , notificationID));

		sendAcknowledge( oblify , notificationID );

		//seperateNotification( oblify->payload , &notification , &notificationID );
	}else {
		notifyWithoutSound( "Device just finished..." , "oblify" , "state information" , "1" );
		DEBUG_PRINT(("error sendoutput\n"));
	}

	if (notification != NULL)
		free( notification );
	if (notificationID != NULL)
		free( notificationID ); // sigabort
}
コード例 #17
0
ファイル: batterynotifier.cpp プロジェクト: AOSC-Dev/lipstick
void BatteryNotifier::applyChargerType(QBatteryInfo::ChargerType type)
{
    switch(type) {
    case QBatteryInfo::UnknownCharger:
        /*
         * After the user plugs out the charger from the device, this system
         * banner is displayed to remind the users to unplug charger from
         * the power supply for conserving energy.  Remove charger
         * notification should not be shown in case if USB cable is used for
         * charging the device.
         */
        if (chargerType == QBatteryInfo::WallCharger) {
            removeNotification(QStringList() << "x-nemo.battery" << "x-nemo.battery.chargingcomplete");
            sendNotification(NotificationRemoveCharger);
        }

#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
        if (chargerType != QBatteryInfo::UnknownCharger && chargerType != QBatteryInfo::USBCharger && batteryInfo->batteryStatus(0) == QBatteryInfo::BatteryLow && batteryInfo->chargingState(0) != QBatteryInfo::Charging) {
#else
        if (chargerType != QBatteryInfo::UnknownCharger && chargerType != QBatteryInfo::USBCharger && batteryInfo->levelStatus() == QBatteryInfo::LevelLow && batteryInfo->chargingState() != QBatteryInfo::Charging) {
#endif
            // A charger was connected but is no longer connected and the battery is low, so start low battery notifier
            startLowBatteryNotifier();
        }
        break;

    default:
        break;
    }

    chargerType = type;
}

void BatteryNotifier::applyPSMState(MeeGo::QmDeviceMode::PSMState psmState)
{
    if (psmState == MeeGo::QmDeviceMode::PSMStateOff) {
        sendNotification(NotificationExitingPSM);
    } else if (psmState == MeeGo::QmDeviceMode::PSMStateOn) {
        sendNotification(NotificationEnteringPSM);
    }
}

void BatteryNotifier::sendNotification(BatteryNotifier::NotificationID id)
{
    switch(id) {
    case NotificationCharging:
        sendNotification("x-nemo.battery",
                //% "Charging"
                qtTrId("qtn_ener_charging"));
        break;

    case NotificationChargingComplete:
        sendNotification("x-nemo.battery.chargingcomplete",
                //% "Charging complete"
                qtTrId("qtn_ener_charcomp"));
        break;

    case NotificationRemoveCharger:
        sendNotification("x-nemo.battery.removecharger",
                //% "Disconnect charger from power supply to save energy"
                qtTrId("qtn_ener_remcha"));
        break;

    case NotificationChargingNotStarted:
        sendNotification("x-nemo.battery.chargingnotstarted",
                //% "Charging not started. Replace charger."
                qtTrId("qtn_ener_repcharger"));
        break;

    case NotificationRechargeBattery:
        sendNotification("x-nemo.battery.recharge",
                //% "Recharge battery"
                qtTrId("qtn_ener_rebatt"));
        break;

    case NotificationEnteringPSM:
        sendNotification("x-nemo.battery.enterpsm",
                //% "Entering power save mode"
                qtTrId("qtn_ener_ent_psnote"));
        break;

    case NotificationExitingPSM:
        sendNotification("x-nemo.battery.exitpsm",
                //% "Exiting power save mode"
                qtTrId("qtn_ener_exit_psnote"));
        break;

    case NotificationLowBattery:
        sendNotification("x-nemo.battery.lowbattery",
                //% "Low battery"
                qtTrId("qtn_ener_lowbatt"));
        break;

    case NotificationNoEnoughPower:
        sendNotification("x-nemo.battery.notenoughpower",
                //% "Not enough power to charge"
                qtTrId("qtn_ener_nopowcharge"), "icon-m-energy-management-insufficient-power");
        break;
    }
}

void BatteryNotifier::sendNotification(const QString &category, const QString &text, const QString &icon)
{
    NotificationManager *manager = NotificationManager::instance();
    QVariantHash hints;
    hints.insert(NotificationManager::HINT_CATEGORY, category);
    hints.insert(NotificationManager::HINT_PREVIEW_BODY, text);
    notificationId = manager->Notify(qApp->applicationName(), 0, icon, QString(), QString(), QStringList(), hints, -1);
    notificationCategory = category;
    notificationTimer.start();
}