Diffstat (limited to 'examples/networksettings/examplemodule.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | examples/networksettings/examplemodule.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/examples/networksettings/examplemodule.cpp b/examples/networksettings/examplemodule.cpp new file mode 100644 index 0000000..d7fd718 --- a/dev/null +++ b/examples/networksettings/examplemodule.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | #include <qwidget.h> | ||
2 | |||
3 | #include <interfaces/interfaceinformationimp.h> | ||
4 | |||
5 | #include "exampleiface.h" | ||
6 | #include "examplemodule.h" | ||
7 | |||
8 | VirtualModule::VirtualModule() { | ||
9 | Interface* iface = new VirtualInterface( 0 ); | ||
10 | iface->setHardwareName( "vpn" ); | ||
11 | iface->setInterfaceName( "Test VPN" ); | ||
12 | m_interfaces.append( iface ); | ||
13 | |||
14 | // If we set up VPN via pptp | ||
15 | // and networksettins was closed and now opened | ||
16 | // we need to hide the ppp device behind us | ||
17 | // One can do this by calling setHandledInterfaceNames | ||
18 | // setHandledInterfaceNames(); | ||
19 | } | ||
20 | |||
21 | VirtualModule::~VirtualModule() { | ||
22 | m_interfaces.setAutoDelete( true ); | ||
23 | m_interfaces.clear(); | ||
24 | } | ||
25 | |||
26 | |||
27 | /* | ||
28 | * We're a VPN module | ||
29 | */ | ||
30 | bool VirtualModule::isOwner( Interface* iface ) { | ||
31 | /* check if it is our device */ | ||
32 | return m_interfaces.find( iface ) != -1; | ||
33 | } | ||
34 | |||
35 | QWidget* VirtualModule::configure( Interface* ) { | ||
36 | /* We don't have any Config for now */ | ||
37 | return 0l; | ||
38 | } | ||
39 | |||
40 | QWidget* VirtualModule::information( Interface* iface ) { | ||
41 | return new InterfaceInformationImp(0, "Interface info", iface ); | ||
42 | } | ||
43 | |||
44 | QList<Interface> VirtualModule::getInterfaces() { | ||
45 | return m_interfaces; | ||
46 | } | ||
47 | |||
48 | void VirtualModule::possibleNewInterfaces( QMap<QString, QString>& map) { | ||
49 | map.insert( QObject::tr("VPN PPTP"), | ||
50 | QObject::tr("Add new Point to Point Tunnel Protocol connection" ) ); | ||
51 | } | ||
52 | |||
53 | |||
54 | Interface* VirtualModule::addNewInterface( const QString& ) { | ||
55 | /* check the str if we support more interfaces */ | ||
56 | /* | ||
57 | Interface* iface = new VirtualInterface( 0 ); | ||
58 | iface->setModuleOwner( this ); | ||
59 | return iface;*/ | ||
60 | |||
61 | // if we would support saving interfaces we could add | ||
62 | // them here | ||
63 | |||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | |||
68 | bool VirtualModule::remove( Interface* ) { | ||
69 | /* we do not support removing our interface */ | ||
70 | return false; | ||
71 | } | ||