<commit_before>#include "systemnotifier.h"
#include <QtDBus>

class SystemNotifierPrivate : public QObject
{
    Q_OBJECT

private slots:
    void networkStateChanged(uint state)
    {
        static const uint NM_STATE_DISCONNECTED = 20;
        static const uint NM_STATE_CONNECTED_GLOBAL = 70;

        if (state == NM_STATE_DISCONNECTED)
            QMetaObject::invokeMethod(SystemNotifier::instance(), "offline");
        else if (state == NM_STATE_CONNECTED_GLOBAL)
            QMetaObject::invokeMethod(SystemNotifier::instance(), "online");
    }
};

void SystemNotifier::initialize()
{
    d = new SystemNotifierPrivate;

    QDBusConnection bus = QDBusConnection::systemBus();
    bus.connect("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager",
                "org.freedesktop.NetworkManager", "StateChanged", d, SLOT(networkStateChanged(uint)));
}

void SystemNotifier::uninitialize()
{
    delete d;
}

#include "systemnotifier_dbus.moc"<commit_msg>Implement SystemNotifier::sleep()/wake() for Linux<commit_after>#include "systemnotifier.h"
#include <QtDBus>

class SystemNotifierPrivate : public QObject
{
    Q_OBJECT

private slots:
    void sleeping()
    {
        QMetaObject::invokeMethod(SystemNotifier::instance(), "sleep");
    }

    void resuming()
    {
        QMetaObject::invokeMethod(SystemNotifier::instance(), "wake");
    }

    void networkStateChanged(uint state)
    {
        static const uint NM_STATE_DISCONNECTED = 20;
        static const uint NM_STATE_CONNECTED_GLOBAL = 70;

        if (state == NM_STATE_DISCONNECTED)
            QMetaObject::invokeMethod(SystemNotifier::instance(), "offline");
        else if (state == NM_STATE_CONNECTED_GLOBAL)
            QMetaObject::invokeMethod(SystemNotifier::instance(), "online");
    }
};

void SystemNotifier::initialize()
{
    d = new SystemNotifierPrivate;

    QDBusConnection bus = QDBusConnection::systemBus();
    bus.connect("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager",
                "org.freedesktop.NetworkManager", "StateChanged", d, SLOT(networkStateChanged(uint)));

    bus.connect("org.freedesktop.UPower", "/org/freedesktop/UPower",
                "org.freedesktop.UPower", "Sleeping", d, SLOT(sleeping()));
    bus.connect("org.freedesktop.UPower", "/org/freedesktop/UPower",
                "org.freedesktop.UPower", "Resuming", d, SLOT(resuming()));
}

void SystemNotifier::uninitialize()
{
    delete d;
}

#include "systemnotifier_dbus.moc"
{'fraction_non_alphanumeric': 0.12454945935122147, 'fraction_numerical': 0.0032038446135362435, 'mean_word_length': 3.9173228346456694, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2885680', 'n_tokens_mistral': 787, 'n_tokens_neox': 761, 'n_words': 132}