summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/profile/profile_NNI.cpp
blob: fc2d809d905f944babacef151e4b1a597fa53bda (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
#include <qpe/qpeapplication.h>
#include <opie2/odebug.h>
#include "profileedit.h"
#include "profile_NNI.h"
#include "profile_NN.h"

AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) {
      Data.Automatic = 1;
      Data.Confirm = 0;
      Data.Description = "";
      Data.Disabled = 0;
      Data.TriggerVPN = 0;
      GUI = 0;
      RT = 0;
}

void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) {

      if ( Attr == "automatic" ) {
        Data.Automatic = (Value=="yes");
      } else if ( Attr == "preconfirm" ) {
        Data.Confirm = (Value=="yes");
      } else if ( Attr == "disabled" ) {
        Data.Disabled = (Value=="yes");
      } else if ( Attr == "triggervpn" ) {
        Data.TriggerVPN = (Value=="yes");
      } else if ( Attr == "description" ) {
        Data.Description = Value;
      }
}

void AProfile::saveSpecificAttribute( QTextStream & TS ) {
      TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl;
      TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl;
      TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl;
      TS << "triggervpn=" << ((Data.TriggerVPN) ? "yes" : "no") << endl;
      TS << "description=" << Data.Description << endl;
}

QWidget * AProfile::edit( QWidget * parent ) {
    GUI = new ProfileEdit( parent, this );
    GUI->showData( Data );
    return GUI;
}

QString AProfile::acceptable( void ) {
    return ( GUI ) ? GUI->acceptable( ) : QString();
}

void AProfile::commit( void ) {
    if( GUI && GUI->commit( Data ) )
      setModified( 1 );
}

short AProfile::generateFileEmbedded( SystemFile & SF,
                                     long DevNr ) {

      short rvl, rvd;

      rvl = 1;

      if( SF.name() == "interfaces" ) {
        Log(("Generate Profile for %s\n", SF.name().latin1() ));
        if( Data.TriggerVPN ) {
          // this profile triggers VPN -> insert trigger
          SF << "  up "
             << QPEApplication::qpeDir() 
             << "bin/networksettings2 --triggervpn " 
             << runtime()->device()->netNode()->nodeClass()->genNic( DevNr )
             << " || true" 
             << endl;
          rvl = 0;
        }
      }
      rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr );
      return (rvd == 2 || rvl == 2 ) ? 2 :
             (rvd == 0 || rvl == 0 ) ? 0 : 1;
}