[OpenDocString] kdeconnect-kde (cpp)
mousepadplugin.cpp
usepadPlugin::MousepadPlugin(QObject *parent, const QVariantList &args)
    : KdeConnectPlugin(parent, args)
    , m_impl(nullptr)
{
#if HAVE_WINDOWS
    m_impl = new WindowsRemoteInput(this);
#elif HAVE_MACOS
    m_impl = new MacOSRemoteInput(this);
#else
#if HAVE_X11
    if (QGuiApplication::platformName() == QLatin1String("xcb")) {
        m_impl = new X11RemoteInput(this);
    }
#endif

#if HAVE_WAYLAND
    if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
        m_impl = new WaylandRemoteInput(this);
    }
#endif
#endif

    if (!m_impl) {
        qDebug() << "KDE Connect was built without" << QGuiApplication::platformName() << "support";
    }
}
Constructs a KdeConnectPlugin object and its m_impl.
usepadPlugin::~MousepadPlugin()
{
    delete m_impl;
}
This removes the mousepad plugin object upon destruction.
ol MousepadPlugin::receivePacket(const NetworkPacket &np)
{
    if (m_impl) {
        return m_impl->handlePacket(np);
    } else {
        return false;
    }
}
It receives a NetworkPacket object np and processes it. The function first checks if the plugin has been initialized and if it is, the function calls the handlePacket method of the plugin based on the impl. Then it returns true. If the plugin has not been initialized, the function returns false.
id MousepadPlugin::connected()
{
    NetworkPacket np(PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE);
    if (m_impl) {
        np.set(QStringLiteral("state"), m_impl->hasKeyboardSupport());
    }
    sendPacket(np);
}
This sends a mousepad keyboard state network packet.