Exemple #1
0
QmSystemState::QmSystemState(QObject *parent)
             : QObject(parent) {
    MEEGO_INITIALIZE(QmSystemState);

    connect(priv, SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication)),
            this, SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication)));
}
Exemple #2
0
QmSystemState::~QmSystemState() {
    MEEGO_PRIVATE(QmSystemState)

    disconnect(priv, SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication)),
               this, SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication)));

    MEEGO_UNINITIALIZE(QmSystemState);
}
ShutdownBusinessLogic::ShutdownBusinessLogic(QObject *parent) :
    QObject(parent),
    shutdownUi(NULL)
{
#ifdef HAVE_QMSYSTEM
    m_State = new MeeGo::QmSystemState(this);
    connect(m_State, SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication)),
        this, SLOT(systemStateChanged(MeeGo::QmSystemState::StateIndication)));
#endif
}
Exemple #4
0
ShutdownScreen::ShutdownScreen(QObject *parent) :
    QObject(parent),
    QDBusContext(),
    window(0),
    systemState(new MeeGo::QmSystemState(this))
{
    connect(systemState, SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication)), this, SLOT(applySystemState(MeeGo::QmSystemState::StateIndication)));
}
ScreenLockBusinessLogic::ScreenLockBusinessLogic(QObject* parent) :
    QObject(parent),
    eventEaterWindow(NULL),
    callbackInterface(NULL),
    shuttingDown(false),
    lockscreenVisible(false)
{
#ifdef HAVE_QMSYSTEM
    connect(&systemState, SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication)), this, SLOT(systemStateChanged(MeeGo::QmSystemState::StateIndication)));
#endif

    // when lipstick tells us the screen is unlocked, tell mce that the screen is unlocked.
    QDBusConnection::sessionBus().connect("org.nemomobile.lipstick", "/request", "org.nemomobile.lipstick", "screenUnlocked", this, SLOT(unlockScreen()));
}
Exemple #6
0
void QmSystemState::connectNotify(const QMetaMethod &signal) {
#else
void QmSystemState::connectNotify(const char *signal) {
#endif
    MEEGO_PRIVATE(QmSystemState)

    /* QObject::connect() needs to be thread-safe */
    QMutexLocker locker(&priv->connectMutex);

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    if (signal == QMetaMethod::fromSignal(&QmSystemState::systemStateChanged)) {
#else
    if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication))))) {
#endif
        if (0 == priv->connectCount[SIGNAL_SYSTEM_STATE]) {
            QDBusConnection::systemBus().connect(dsme_service,
                                                 dsme_sig_path,
                                                 dsme_sig_interface,
                                                 dsme_shutdown_ind,
                                                 priv,
                                                 SLOT(emitShutdown()));
            QDBusConnection::systemBus().connect(dsme_service,
                                                 dsme_sig_path,
                                                 dsme_sig_interface,
                                                 dsme_save_unsaved_data_ind,
                                                 priv,
                                                 SLOT(emitSaveData()));
            QDBusConnection::systemBus().connect(dsme_service,
                                                 dsme_sig_path,
                                                 dsme_sig_interface,
                                                 dsme_battery_empty_ind,
                                                 priv,
                                                 SLOT(emitBatteryShutdown()));
            QDBusConnection::systemBus().connect(dsme_service,
                                                 dsme_sig_path,
                                                 dsme_sig_interface,
                                                 dsme_state_req_denied_ind,
                                                 priv,
                                                 SLOT(emitShutdownDenied(QString, QString)));
            QDBusConnection::systemBus().connect(SYS_THERMALMANAGER_SERVICE,
                                                 SYS_THERMALMANAGER_PATH,
                                                 SYS_THERMALMANAGER_INTERFACE,
                                                 SYS_THERMALMANAGER_STATE_SIG,
                                                 priv,
                                                 SLOT(emitThermalShutdown(QString)));
        }
        priv->connectCount[SIGNAL_SYSTEM_STATE]++;
    }
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
void QmSystemState::disconnectNotify(const QMetaMethod &signal) {
#else
void QmSystemState::disconnectNotify(const char *signal) {
#endif
    MEEGO_PRIVATE(QmSystemState)

    /* QObject::disconnect() needs to be thread-safe */
    QMutexLocker locker(&priv->connectMutex);

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    if (signal == QMetaMethod::fromSignal(&QmSystemState::systemStateChanged)) {
#else
    if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL(systemStateChanged(MeeGo::QmSystemState::StateIndication))))) {
#endif
        priv->connectCount[SIGNAL_SYSTEM_STATE]--;

        if (0 == priv->connectCount[SIGNAL_SYSTEM_STATE]) {
            QDBusConnection::systemBus().disconnect(dsme_service,
                                                    dsme_sig_path,
                                                    dsme_sig_interface,
                                                    dsme_shutdown_ind,
                                                    priv,
                                                    SLOT(emitShutdown()));
            QDBusConnection::systemBus().disconnect(dsme_service,
                                                    dsme_sig_path,
                                                    dsme_sig_interface,
                                                    dsme_save_unsaved_data_ind,
                                                    priv,
                                                    SLOT(emitSaveData()));
            QDBusConnection::systemBus().disconnect(dsme_service,
                                                    dsme_sig_path,
                                                    dsme_sig_interface,
                                                    dsme_battery_empty_ind,
                                                    priv,
                                                    SLOT(emitBatteryShutdown()));
            QDBusConnection::systemBus().disconnect(dsme_service,
                                                    dsme_sig_path,
                                                    dsme_sig_interface,
                                                    dsme_state_req_denied_ind,
                                                    priv,
                                                    SLOT(emitShutdownDenied(QString, QString)));
            QDBusConnection::systemBus().disconnect(SYS_THERMALMANAGER_SERVICE,
                                                    SYS_THERMALMANAGER_PATH,
                                                    SYS_THERMALMANAGER_INTERFACE,
                                                    SYS_THERMALMANAGER_STATE_SIG,
                                                    priv,
                                                    SLOT(emitThermalShutdown(QString)));
        }
    }
}

bool QmSystemState::set(NextState nextState) {
    MEEGO_PRIVATE(QmSystemState)

    QString method;
    switch (nextState) {
        case Powerup:
            method = QString(dsme_req_powerup);
            break;
        case Reboot:
            method = QString(dsme_req_reboot);
            break;
        case ShuttingDown:
            method = QString(dsme_req_shutdown);
            break;
        default:
            return false;
    }
    QmIPCInterface *requestIf = priv->dsmeRequestIf;
    requestIf->callAsynchronously(method);
    return true;
}