00001 #include <stdio.h>
00002 #include <qcombobox.h>
00003 #include <qmessagebox.h>
00004 #include <qradiobutton.h>
00005 #include <qlineedit.h>
00006 #include <GUIUtils.h>
00007 #include "PPPAuthedit.h"
00008
00009 PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){
00010 }
00011
00012 bool PPPAuthEdit::PAP_Checked( void ) {
00013 return ( Pap_RB->isChecked() ||
00014 Chap_RB->isChecked() ||
00015 EAP_RB->isChecked()
00016 );
00017 }
00018
00019 QString PPPAuthEdit::acceptable( void ) {
00020 if( Login_RB->isChecked() ) {
00021 if( LoginSend_LE->text().isEmpty() )
00022 return tr("Login send missing");
00023 if( LoginExpect_LE->text().isEmpty() )
00024 return tr("Login expect missing");
00025 if( PasswordSend_LE->text().isEmpty() )
00026 return tr("Password send missing");
00027 if( PasswordExpect_LE->text().isEmpty() )
00028 return tr("Password expect missing");
00029 } else if( PAP_Checked() ) {
00030 if( Client_LE->text().isEmpty() )
00031 return tr("Pap/Chap/EAP client id missing");
00032 if( Server_LE->text().isEmpty() )
00033 return tr("Pap/Chap/EAP server id missing");
00034 if( Secret_LE->text().isEmpty() )
00035 return tr("Pap/Chap/EAP secret id missing");
00036 }
00037 return QString();
00038 }
00039
00040 bool PPPAuthEdit::commit( PPPData & D ) {
00041 bool SM = 0;
00042
00043 if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) ||
00044 ( D.Auth.Mode == 1 && ! PAP_Checked() ) ||
00045 ( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) {
00046
00047 SM = 1;
00048 D.Auth.Mode = ( Login_RB->isChecked() ) ?
00049 0 :
00050 ( PAP_Checked() ) ? 1 : 2;
00051 }
00052
00053 if( Login_RB->isChecked() ) {
00054 TXTM( D.Auth.Login.Expect, LoginExpect_LE, SM );
00055 TXTM( D.Auth.Login.Send, LoginSend_LE, SM );
00056 TXTM( D.Auth.Password.Expect, PasswordExpect_LE, SM );
00057 TXTM( D.Auth.Password.Send, PasswordSend_LE, SM );
00058 } else if( PAP_Checked() ) {
00059 TXTM( D.Auth.Client, Client_LE, SM );
00060 TXTM( D.Auth.Server, Server_LE, SM );
00061 TXTM( D.Auth.Secret, Secret_LE, SM );
00062 if( Pap_RB->isChecked() ) {
00063 D.Auth.PCEMode = 0;
00064 } else if( Chap_RB->isChecked() ) {
00065 D.Auth.PCEMode = 1;
00066 } else if( EAP_RB->isChecked() ) {
00067 D.Auth.PCEMode = 2;
00068 }
00069 }
00070 return SM;
00071 }
00072
00073 void PPPAuthEdit::showData( PPPData & D ) {
00074
00075 switch( D.Auth.Mode ) {
00076 case 0 :
00077 Login_RB->setChecked( TRUE );
00078 break;
00079 case 1 :
00080 switch( D.Auth.PCEMode ) {
00081 case 0 :
00082 Pap_RB->setChecked( TRUE );
00083 break;
00084 case 1 :
00085 Chap_RB->setChecked( TRUE );
00086 break;
00087 case 2 :
00088 EAP_RB->setChecked( TRUE );
00089 break;
00090 }
00091 break;
00092 case 2 :
00093 Terminal_RB->setChecked( TRUE );
00094 break;
00095 }
00096
00097 LoginExpect_LE->setText( D.Auth.Login.Expect );
00098 PasswordExpect_LE->setText( D.Auth.Password.Expect );
00099 LoginSend_LE->setText( D.Auth.Login.Send );
00100 PasswordSend_LE->setText( D.Auth.Password.Send );
00101
00102 Client_LE->setText( D.Auth.Client );
00103 Server_LE->setText( D.Auth.Server );
00104 Secret_LE->setText( D.Auth.Secret );
00105 }