[OpenDocString] kdeconnect-kde (cpp)
kdeconnectplugin.cpp
KdeConnectPlugin::KdeConnectPlugin(QObject *parent, const QVariantList &args)
    : QObject(parent)
    , d(new KdeConnectPluginPrivate)
{
    d->m_device = qvariant_cast(args.at(0));
    d->m_pluginName = args.at(1).toString();
    d->m_outgoingCapabilties = args.at(2).toStringList().toSet();
    d->m_config = nullptr;
    d->iconName = args.at(3).toString();
}
Constructs a KdeConnectPlugin object and assigns device, plugin name, capabilities and icon to the internal d pointer.
KdeConnectPluginConfig *KdeConnectPlugin::config() const
{
    // Create on demand, because not every plugin will use it
    if (!d->m_config) {
        d->m_config = new KdeConnectPluginConfig(d->m_device->id(), d->m_pluginName);
    }
    return d->m_config;
}
Returns the config object, and creates it if it doesn't exist.
KdeConnectPlugin::~KdeConnectPlugin()
{
    if (d->m_config) {
        delete d->m_config;
    }
}
Deletes the configuration object upon destruction.
const Device *KdeConnectPlugin::device()
{
    return d->m_device;
}
Returns a pointer to the device object.
Device const *KdeConnectPlugin::device() const
{
    return d->m_device;
}
Returns the pointer to the device object, in a const method.
bool KdeConnectPlugin::sendPacket(NetworkPacket &np) const
{
    if (!d->m_outgoingCapabilties.contains(np.type())) {
        qCWarning(KDECONNECT_CORE) << metaObject()->className() << "tried to send an unsupported packet type" << np.type()
                                   << ". Supported:" << d->m_outgoingCapabilties;
        return false;
    }
    //     qCWarning(KDECONNECT_CORE) << metaObject()->className() << "sends" << np.type() << ". Supported:" << d->mOutgoingTypes;
    return d->m_device->sendPacket(np);
}
This sends a network packet, if possible.
QString KdeConnectPlugin::dbusPath() const
{
    return {};
}
Returns an empty dbus path.
QString KdeConnectPlugin::iconName() const
{
    return d->iconName;
}
Returns the icon name as a QString.