summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/network/network_NN.cpp
blob: 23b3d44d638dc2a7ac8e1fb56332cfaa7c23add4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <qpe/qpeapplication.h>
#include <resources.h>
#include <netnode.h>
#include "network_NN.h"
#include "network_NNI.h"

static const char * NetworkNeeds[] = 
    { "device", 
      0
    };

static const char * NetworkProvides[] = 
    { "connection",
      0
    };

/**
 * Constructor, find all of the possible interfaces
 */
NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) {

      NSResources->addSystemFile(
        "interfaces", "/etc/network/interfaces", 1 );
}

/**
 * Delete any interfaces that we own.
 */
NetworkNetNode::~NetworkNetNode(){
}

const QString NetworkNetNode::nodeDescription(){
      return tr("\
<p>Sets up TCP/IP options.</p>\
<p>Use this to configure the TCP/IP protocol</p>\
"
);
}

ANetNodeInstance * NetworkNetNode::createInstance( void ) {
      return new ANetwork( this );
}

bool NetworkNetNode::hasDataForFile( SystemFile & S ) {
      return S.name() == "interfaces";
}

short NetworkNetNode::generateFile( SystemFile & SF, 
                                   ANetNodeInstance * NNI,
                                   long DevNr ) {
                                   
      if( DevNr < 0 ) {
        // generate device specific but common part
        return 1;
      }

      QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr );

      if( SF.name() == "interfaces" ) {
        Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() ));
        // generate mapping stanza for this interface
        SF << "# check if " 
           << NIC 
           << " can be brought UP" 
           << endl;
        SF << "mapping " 
           << NIC 
           << endl;
        SF << "  script "
           << QPEApplication::qpeDir()
           << "bin/networksettings2-request" 
           << endl 
           << endl;
        return 0;
      }
      return 1;
}

const char ** NetworkNetNode::needs( void ) {
      return NetworkNeeds;
}

const char ** NetworkNetNode::provides( void ) {
      return NetworkProvides;
}

void NetworkNetNode::setSpecificAttribute( QString & , QString & ) {
}

void NetworkNetNode::saveSpecificAttribute( QTextStream & ) {
}

extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
      PNN.append( new NetworkNetNode() );
}
}