You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.2 KiB
134 lines
4.2 KiB
15 years ago
|
/*
|
||
|
* This file is part of the KDE libraries
|
||
13 years ago
|
* Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
|
||
15 years ago
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License version 2 as published by the Free Software Foundation.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
**/
|
||
|
|
||
|
#include "kmwpassword.h"
|
||
|
#include "kmwizard.h"
|
||
|
#include "kmprinter.h"
|
||
|
|
||
15 years ago
|
#include <tqlabel.h>
|
||
|
#include <tqlineedit.h>
|
||
|
#include <tqvbuttongroup.h>
|
||
|
#include <tqradiobutton.h>
|
||
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <klocale.h>
|
||
|
#include <kcursor.h>
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
|
||
15 years ago
|
KMWPassword::KMWPassword(TQWidget *parent, const char *name)
|
||
15 years ago
|
: KMWizardPage(parent,name)
|
||
|
{
|
||
|
m_title = i18n("User Identification");
|
||
|
m_ID = KMWizard::Password;
|
||
|
m_nextpage = KMWizard::SMB;
|
||
|
|
||
|
// create widgets
|
||
14 years ago
|
TQLabel *infotext_ = new TQLabel(this);
|
||
15 years ago
|
infotext_->setText(i18n("<p>This backend may require a login/password to work properly. "
|
||
|
"Select the type of access to use and fill in the login and password entries if needed.</p>"));
|
||
15 years ago
|
m_login = new TQLineEdit(this);
|
||
|
m_login->setText(TQString::fromLocal8Bit(getenv("USER")));
|
||
|
m_password = new TQLineEdit(this);
|
||
|
m_password->setEchoMode(TQLineEdit::Password);
|
||
14 years ago
|
TQLabel *loginlabel_ = new TQLabel(i18n("&Login:"),this);
|
||
|
TQLabel *passwdlabel_ = new TQLabel(i18n("&Password:"),this);
|
||
15 years ago
|
m_btngroup = new TQVButtonGroup( this );
|
||
|
m_btngroup->setFrameStyle( TQFrame::NoFrame );
|
||
|
TQRadioButton *btn1 = new TQRadioButton( i18n( "&Anonymous (no login/password)" ), m_btngroup );
|
||
|
TQRadioButton *btn2 = new TQRadioButton( i18n( "&Guest account (login=\"guest\")" ), m_btngroup );
|
||
|
TQRadioButton *btn3 = new TQRadioButton( i18n( "Nor&mal account" ), m_btngroup );
|
||
15 years ago
|
btn1->setCursor( KCursor::handCursor() );
|
||
|
btn2->setCursor( KCursor::handCursor() );
|
||
|
btn3->setCursor( KCursor::handCursor() );
|
||
|
m_btngroup->setButton( 0 );
|
||
|
|
||
|
loginlabel_->setBuddy(m_login);
|
||
|
passwdlabel_->setBuddy(m_password);
|
||
|
|
||
|
m_login->setEnabled(false);
|
||
|
m_password->setEnabled(false);
|
||
15 years ago
|
connect(btn3,TQT_SIGNAL(toggled(bool)),m_login,TQT_SLOT(setEnabled(bool)));
|
||
|
connect(btn3,TQT_SIGNAL(toggled(bool)),m_password,TQT_SLOT(setEnabled(bool)));
|
||
15 years ago
|
|
||
14 years ago
|
// layout
|
||
15 years ago
|
TQVBoxLayout *main_ = new TQVBoxLayout( this, 0, 0 );
|
||
15 years ago
|
main_->addWidget( infotext_ );
|
||
|
main_->addSpacing( 10 );
|
||
|
main_->addWidget( m_btngroup );
|
||
15 years ago
|
TQGridLayout *l1 = new TQGridLayout( 0, 2, 3 );
|
||
14 years ago
|
main_->addLayout( TQT_TQLAYOUT(l1) );
|
||
15 years ago
|
main_->addStretch( 1 );
|
||
|
l1->setColSpacing( 0, 35 );
|
||
|
l1->setColStretch( 2, 1 );
|
||
|
l1->addWidget( loginlabel_, 0, 1 );
|
||
|
l1->addWidget( passwdlabel_, 1, 1 );
|
||
|
l1->addWidget( m_login, 0, 2 );
|
||
|
l1->addWidget( m_password, 1, 2 );
|
||
|
}
|
||
|
|
||
15 years ago
|
bool KMWPassword::isValid(TQString& msg)
|
||
15 years ago
|
{
|
||
|
if ( !m_btngroup->selected() )
|
||
|
msg = i18n( "Select one option" );
|
||
|
else if (m_btngroup->selectedId() == 2 && m_login->text().isEmpty())
|
||
|
msg = i18n("User name is empty.");
|
||
|
else
|
||
|
return true;
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
void KMWPassword::initPrinter( KMPrinter* p )
|
||
|
{
|
||
|
/* guest account only for SMB backend */
|
||
|
if ( p->option( "kde-backend" ).toInt() != KMWizard::SMB )
|
||
|
{
|
||
|
int ID = m_btngroup->selectedId();
|
||
14 years ago
|
m_btngroup->find( 1 )->hide();
|
||
15 years ago
|
if ( ID == 1 )
|
||
|
m_btngroup->setButton( 0 );
|
||
|
}
|
||
|
else
|
||
14 years ago
|
m_btngroup->find( 1 )->show();
|
||
15 years ago
|
}
|
||
|
|
||
|
void KMWPassword::updatePrinter(KMPrinter *p)
|
||
|
{
|
||
14 years ago
|
TQString s = p->option("kde-backend");
|
||
15 years ago
|
if (!s.isEmpty())
|
||
|
setNextPage(s.toInt());
|
||
|
else
|
||
|
setNextPage(KMWizard::Error);
|
||
|
switch ( m_btngroup->selectedId() )
|
||
|
{
|
||
|
case 0:
|
||
15 years ago
|
p->setOption( "kde-login", TQString::null );
|
||
|
p->setOption( "kde-password", TQString::null );
|
||
15 years ago
|
break;
|
||
|
case 1:
|
||
14 years ago
|
p->setOption( "kde-login", TQString::tqfromLatin1( "guest" ) );
|
||
15 years ago
|
p->setOption( "kde-password", TQString::null );
|
||
15 years ago
|
break;
|
||
|
case 2:
|
||
|
p->setOption( "kde-login", m_login->text() );
|
||
|
p->setOption( "kde-password", m_password->text() );
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|