Solid
tutorial5.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <QList>
00022
00023
00024 #include <solid/deviceinterface.h>
00025 #include <solid/networking.h>
00026 #include <solid/device.h>
00027 #include <solid/networkinterface.h>
00028
00029
00030 #include <kcomponentdata.h>
00031 #include <kcmdlineargs.h>
00032 #include <klocale.h>
00033 #include <kdebug.h>
00034
00035 #include <iostream>
00036
00037 using namespace std;
00038
00039 int main(int args, char **argv)
00040 {
00041 KComponentData data("tutorial5");
00042
00043
00044 QList<Solid::Device> netlist = Solid::Device::listFromType(Solid::DeviceInterface::NetworkInterface, QString());
00045
00046
00047 if(netlist.empty())
00048 {
00049 kDebug() << "No network devices found!";
00050 return 0;
00051 }
00052
00053 Solid::Device device = netlist[0];
00054 Solid::NetworkInterface *netdev = device.as<Solid::NetworkInterface>();
00055
00056 if(!netdev)
00057 {
00058 kDebug() << "Device could not be converted. There is a bug.";
00059 return 0;
00060 }
00061
00062 kDebug() << "The iface of " << device.udi() << " is " << netdev->ifaceName();
00063
00064 return 0;
00065 }
00066
00067 #include "tutorial5.moc"