Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

profile_NNI.cpp

Go to the documentation of this file.
00001 #include <qpe/qpeapplication.h>
00002 #include <opie2/odebug.h>
00003 #include "profileedit.h"
00004 #include "profile_NNI.h"
00005 #include "profile_NN.h"
00006 
00007 AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) {
00008       Data.Automatic = 1;
00009       Data.Confirm = 0;
00010       Data.Description = "";
00011       Data.Enabled = 1;
00012       Data.TriggerVPN = 0;
00013       GUI = 0;
00014       RT = 0;
00015 }
00016 
00017 void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) {
00018 
00019       if ( Attr == "automatic" ) {
00020         Data.Automatic = (Value=="yes");
00021       } else if ( Attr == "preconfirm" ) {
00022         Data.Confirm = (Value=="yes");
00023       } else if ( Attr == "disabled" ) {
00024         Data.Enabled = (Value=="no");
00025       } else if ( Attr == "enabled" ) {
00026         Data.Enabled = (Value=="yes");
00027       } else if ( Attr == "triggervpn" ) {
00028         Data.TriggerVPN = (Value=="yes");
00029       } else if ( Attr == "description" ) {
00030         Data.Description = Value;
00031       }
00032 }
00033 
00034 void AProfile::saveSpecificAttribute( QTextStream & TS ) {
00035       TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl;
00036       TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl;
00037       TS << "enabled=" << ((Data.Enabled) ? "yes" : "no") << endl;
00038       TS << "triggervpn=" << ((Data.TriggerVPN) ? "yes" : "no") << endl;
00039       TS << "description=" << Data.Description << endl;
00040 }
00041 
00042 QWidget * AProfile::edit( QWidget * parent ) {
00043     GUI = new ProfileEdit( parent, this );
00044     GUI->showData( Data );
00045     return GUI;
00046 }
00047 
00048 QString AProfile::acceptable( void ) {
00049     return ( GUI ) ? GUI->acceptable( ) : QString();
00050 }
00051 
00052 void AProfile::commit( void ) {
00053     if( GUI && GUI->commit( Data ) )
00054       setModified( 1 );
00055 }
00056 
00057 short AProfile::generateFileEmbedded( SystemFile & SF,
00058                                      long DevNr ) {
00059 
00060       short rvl, rvd;
00061 
00062       rvl = 1;
00063 
00064       if( SF.name() == "interfaces" ) {
00065         Log(("Generate Profile for %s\n", SF.name().latin1() ));
00066         if( Data.TriggerVPN ) {
00067           // this profile triggers VPN -> insert trigger
00068           SF << "  up "
00069              << QPEApplication::qpeDir() 
00070              << "bin/networksettings2 --triggervpn " 
00071              << runtime()->device()->netNode()->nodeClass()->genNic( DevNr )
00072              << " || true" 
00073              << endl;
00074           rvl = 0;
00075         }
00076       }
00077       rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr );
00078       return (rvd == 2 || rvl == 2 ) ? 2 :
00079              (rvd == 0 || rvl == 0 ) ? 0 : 1;
00080 }
00081 
00082 
00083 

Generated on Sat Nov 5 16:17:56 2005 for OPIE by  doxygen 1.4.2