KySdkNetCard(3)

πŸ“¦ version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

πŸ’– KySdkNetCard β€” the D-Bus signal class for network card info πŸ’–

okay bestie, sit down, hydrate, because we're about to get to know KySdkNetCard, a little class from the KySdk Network Card Library manual (section 3 of the manuals, if you're keeping score πŸŽ€). It lives in <kysdkdbus.h> and it inherits from QObject. That's the whole vibe: it's the class that generates D-Bus signals so you can pull network card info without crying.


✨ NAME ✨

KySdkNetCard β€” a D-Bus signal class for generating network card information. no cap, that's literally its job description πŸ’…


🌸 SYNOPSIS 🌸

#include <kysdkdbus.h>

Inherits from QObject.


πŸ¦‹ DESCRIPTION πŸ¦‹

So KySdkNetCard is mainly there to generate D-Bus signals for network card information. And when we say network card information, we mean all of it, queen: getting the network card list, MAC address, IP address, subnet mask, gateway, DNS servers, connection status, speed, duplex mode, and other network interface information. it's giving "one class, all the tea" β˜•


πŸ‘‘ PUBLIC SLOTS πŸ‘‘

Nine slots. Nine chances to be that girl. Let's go πŸ’…

  • QStringList getNetCardList () const β€” Get the list of all network cards.
    • Return value:
      • QStringList β€” List of network card names ✨
  • QString getNetCardMacAddress (const QString cardName) const β€” Get the MAC address of the specified network card.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • QString β€” MAC address of the network card πŸŽ€
  • QString getNetCardIpAddress (const QString cardName) const β€” Get the IP address of the specified network card.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • QString β€” IP address of the network card 🌈
  • QString getNetCardSubnetMask (const QString cardName) const β€” Get the subnet mask of the specified network card.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • QString β€” Subnet mask of the network card πŸ¦‹
  • QString getNetCardGateway (const QString cardName) const β€” Get the gateway of the specified network card.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • QString β€” Gateway of the network card πŸšͺ✨
  • QStringList getNetCardDnsServers (const QString cardName) const β€” Get the DNS servers of the specified network card.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • QStringList β€” DNS server addresses list πŸ’œ
  • bool isNetCardConnected (const QString cardName) const β€” Check if the specified network card is connected.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • bool β€” Connection status (true if connected, false otherwise) βœ…
  • int getNetCardSpeed (const QString cardName) const β€” Get the speed of the specified network card.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • int β€” Speed of the network card in Mbps πŸ”₯
  • QString getNetCardDuplexMode (const QString cardName) const β€” Get the duplex mode of the specified network card.
    • Parameters:
      • cardName β€” Network card name
    • Return value:
      • QString β€” Duplex mode ("full", "half", or "unknown") 🧚

🌟 EXAMPLE USAGE 🌟

here's the whole thing in action, copy-paste ready, no notes (jk there are notes, scroll down):

#include <kysdkdbus.h>
#include <QCoreApplication>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    KySdkNetCard netCardInfo;

    // Get network card list
    QStringList netCards = netCardInfo.getNetCardList();
    qDebug() << "Network cards:" << netCards;

    // Get information of the first network card
    if (!netCards.isEmpty()) {
        QString cardName = netCards.first();

        QString macAddr = netCardInfo.getNetCardMacAddress(cardName);
        QString ipAddr = netCardInfo.getNetCardIpAddress(cardName);
        QString subnetMask = netCardInfo.getNetCardSubnetMask(cardName);
        QString gateway = netCardInfo.getNetCardGateway(cardName);
        QStringList dnsServers = netCardInfo.getNetCardDnsServers(cardName);
        bool isConnected = netCardInfo.isNetCardConnected(cardName);
        int speed = netCardInfo.getNetCardSpeed(cardName);
        QString duplexMode = netCardInfo.getNetCardDuplexMode(cardName);

        qDebug() << "Network card:" << cardName;
        qDebug() << "  MAC Address:" << macAddr;
        qDebug() << "  IP Address:" << ipAddr;
        qDebug() << "  Subnet Mask:" << subnetMask;
        qDebug() << "  Gateway:" << gateway;
        qDebug() << "  DNS Servers:" << dnsServers;
        qDebug() << "  Connected:" << isConnected;
        qDebug() << "  Speed:" << speed << "Mbps";
        qDebug() << "  Duplex Mode:" << duplexMode;
    }

    return 0;
}

πŸŽ€ NOTES πŸŽ€

little things to keep in your head, bestie, don't skip these:

  • IP address, subnet mask, and gateway are returned as string format
  • DNS servers are returned as a list of string addresses
  • Speed is returned in Mbps (Megabits per second)
  • Duplex mode can be "full", "half", or "unknown"
  • Connection status returns true if the network card is active and connected
fr fr, don't forget these β€” they're the difference between code that slays and code that's just confused πŸ’€

πŸ” SEE ALSO πŸ”

QObject(3qt5), D-Bus(1), ifconfig(8), ip(8), nmcli(1) β€” go read those too, iykyk 🫢


πŸ’œ AUTHOR πŸ’œ

Generated automatically by Doxygen for kysdkdbus.h from the source code. (the robots did it, not us πŸ™ˆ)


and that's a wrap on the KySdkNetCard manual page, version 1.0, dated Wed Sep 20 2023, straight from the KySdk Network Card Library. periodt. go get your network card info, icon πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from