* Added some infrastructure created by OpenSUSE to allow for future addition of the Kickoff menu as an option * Minor Slackware compilation fixes git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1171255 283d02a7-25f6-0310-bc7c-ecb5cbfe19dav3.5.13-sru
@ -0,0 +1,176 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Admin dialog
|
||||||
|
|
||||||
|
Copyright (C) 1997, 1998, 2000 Steffen Hansen <hansen@kde.org>
|
||||||
|
Copyright (C) 2000-2003 Oswald Buddenhagen <ossi@kde.org>
|
||||||
|
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kdmadmindialog.h"
|
||||||
|
#include "kdmconfig.h"
|
||||||
|
#include "kgdialog.h"
|
||||||
|
#include "kdm_greet.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <kapplication.h>
|
||||||
|
#include <kseparator.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kpushbutton.h>
|
||||||
|
#include <kstdguiitem.h>
|
||||||
|
|
||||||
|
#include <tqcombobox.h>
|
||||||
|
#include <tqvbuttongroup.h>
|
||||||
|
#include <tqstyle.h>
|
||||||
|
#include <tqlayout.h>
|
||||||
|
#include <tqaccel.h>
|
||||||
|
#include <tqpopupmenu.h>
|
||||||
|
|
||||||
|
int KDMAdmin::curPlugin = -1;
|
||||||
|
PluginList KDMAdmin::pluginList;
|
||||||
|
|
||||||
|
KDMAdmin::KDMAdmin( const TQString &user, TQWidget *_parent )
|
||||||
|
: inherited( _parent )
|
||||||
|
, verify( 0 ), curUser(user)
|
||||||
|
{
|
||||||
|
TQSizePolicy fp( TQSizePolicy::Fixed, TQSizePolicy::Fixed );
|
||||||
|
|
||||||
|
TQVBoxLayout *box = new TQVBoxLayout( this, 10 );
|
||||||
|
|
||||||
|
TQHBoxLayout *hlay = new TQHBoxLayout( box );
|
||||||
|
|
||||||
|
GSendInt( G_ReadDmrc );
|
||||||
|
GSendStr( "root" );
|
||||||
|
GRecvInt(); // ignore status code ...
|
||||||
|
|
||||||
|
if (curPlugin < 0) {
|
||||||
|
curPlugin = 0;
|
||||||
|
pluginList = KGVerify::init( "classic" );
|
||||||
|
}
|
||||||
|
verify = new KGStdVerify( this, this,
|
||||||
|
this, "root",
|
||||||
|
pluginList, KGreeterPlugin::Authenticate,
|
||||||
|
KGreeterPlugin::Shutdown );
|
||||||
|
verify->selectPlugin( curPlugin );
|
||||||
|
box->addLayout( verify->getLayout() );
|
||||||
|
TQAccel *accel = new TQAccel( this );
|
||||||
|
accel->insertItem( ALT+Key_A, 0 );
|
||||||
|
connect( accel, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivatePlugMenu()) );
|
||||||
|
|
||||||
|
box->addWidget( new KSeparator( KSeparator::HLine, this ) );
|
||||||
|
|
||||||
|
okButton = new KPushButton( KStdGuiItem::ok(), this );
|
||||||
|
okButton->setSizePolicy( fp );
|
||||||
|
okButton->setDefault( true );
|
||||||
|
cancelButton = new KPushButton( KStdGuiItem::cancel(), this );
|
||||||
|
cancelButton->setSizePolicy( fp );
|
||||||
|
|
||||||
|
hlay = new TQHBoxLayout( box );
|
||||||
|
hlay->addStretch( 1 );
|
||||||
|
hlay->addWidget( okButton );
|
||||||
|
hlay->addStretch( 1 );
|
||||||
|
hlay->addWidget( cancelButton );
|
||||||
|
hlay->addStretch( 1 );
|
||||||
|
|
||||||
|
connect( okButton, TQT_SIGNAL(clicked()), TQT_SLOT(accept()) );
|
||||||
|
connect( cancelButton, TQT_SIGNAL(clicked()), TQT_SLOT(reject()) );
|
||||||
|
|
||||||
|
slotWhenChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
KDMAdmin::~KDMAdmin()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
delete verify;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::slotActivatePlugMenu()
|
||||||
|
{
|
||||||
|
TQPopupMenu *cmnu = verify->getPlugMenu();
|
||||||
|
TQSize sh( cmnu->sizeHint() / 2 );
|
||||||
|
cmnu->exec( geometry().center() - TQPoint( sh.width(), sh.height() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::accept()
|
||||||
|
{
|
||||||
|
verify->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::slotWhenChanged()
|
||||||
|
{
|
||||||
|
verify->abort();
|
||||||
|
verify->setEnabled( 1 );
|
||||||
|
verify->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::bye_bye()
|
||||||
|
{
|
||||||
|
GSendInt( G_GetDmrc );
|
||||||
|
GSendStr( "Session" );
|
||||||
|
char *sess = GRecvStr();
|
||||||
|
if (sess && strcmp(sess, "admin")) {
|
||||||
|
GSendInt( G_PutDmrc );
|
||||||
|
GSendStr( "OrigSession");
|
||||||
|
GSendStr( sess);
|
||||||
|
free(sess);
|
||||||
|
}
|
||||||
|
|
||||||
|
GSendInt( G_PutDmrc );
|
||||||
|
GSendStr( "Session" );
|
||||||
|
GSendStr( "admin" );
|
||||||
|
inherited::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::verifyPluginChanged( int id )
|
||||||
|
{
|
||||||
|
curPlugin = id;
|
||||||
|
adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::verifyOk()
|
||||||
|
{
|
||||||
|
bye_bye();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::verifyFailed()
|
||||||
|
{
|
||||||
|
okButton->setEnabled( false );
|
||||||
|
cancelButton->setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::verifyRetry()
|
||||||
|
{
|
||||||
|
okButton->setEnabled( true );
|
||||||
|
cancelButton->setEnabled( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KDMAdmin::verifySetUser( const TQString & )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "kdmadmindialog.moc"
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Shutdown dialog
|
||||||
|
|
||||||
|
Copyright (C) 1997, 1998 Steffen Hansen <hansen@kde.org>
|
||||||
|
Copyright (C) 2000-2003 Oswald Buddenhagen <ossi@kde.org>
|
||||||
|
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef KDMADMIN_H
|
||||||
|
#define KDMADMIN_H
|
||||||
|
|
||||||
|
#include "kgverify.h"
|
||||||
|
|
||||||
|
#include <tqradiobutton.h>
|
||||||
|
|
||||||
|
class LiloInfo;
|
||||||
|
class TQLabel;
|
||||||
|
class KPushButton;
|
||||||
|
class TQButtonGroup;
|
||||||
|
class TQComboBox;
|
||||||
|
|
||||||
|
class KDMAdmin : public FDialog, public KGVerifyHandler {
|
||||||
|
Q_OBJECT
|
||||||
|
typedef FDialog inherited;
|
||||||
|
|
||||||
|
public:
|
||||||
|
KDMAdmin( const TQString &user, TQWidget *_parent = 0 );
|
||||||
|
~KDMAdmin();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept();
|
||||||
|
void slotWhenChanged();
|
||||||
|
void slotActivatePlugMenu();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void bye_bye();
|
||||||
|
|
||||||
|
KPushButton *okButton, *cancelButton;
|
||||||
|
KGStdVerify *verify;
|
||||||
|
TQString curUser;
|
||||||
|
|
||||||
|
static int curPlugin;
|
||||||
|
static PluginList pluginList;
|
||||||
|
|
||||||
|
public: // from KGVerifyHandler
|
||||||
|
virtual void verifyPluginChanged( int id );
|
||||||
|
virtual void verifyOk();
|
||||||
|
virtual void verifyFailed();
|
||||||
|
virtual void verifyRetry();
|
||||||
|
virtual void verifySetUser( const TQString &user );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,7 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Type=XSession
|
||||||
|
Exec=YaSTadminSession
|
||||||
|
TryExec=YaSTadminSession
|
||||||
|
Name=admin
|
||||||
|
Comment=Yast Admin Session
|
@ -0,0 +1,668 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Conversation widget for kdm greeter
|
||||||
|
|
||||||
|
Copyright (C) 2008 Dirk Mueller <mueller@kde.org>
|
||||||
|
|
||||||
|
based on classic kdm greeter:
|
||||||
|
|
||||||
|
Copyright (C) 1997, 1998, 2000 Steffen Hansen <hansen@kde.org>
|
||||||
|
Copyright (C) 2000-2003 Oswald Buddenhagen <ossi@kde.org>
|
||||||
|
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kgreet_pam.h"
|
||||||
|
#include "themer/kdmthemer.h"
|
||||||
|
#include "themer/kdmlabel.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <klineedit.h>
|
||||||
|
#include <kpassdlg.h>
|
||||||
|
#include <kuser.h>
|
||||||
|
|
||||||
|
#include <tqregexp.h>
|
||||||
|
#include <tqlayout.h>
|
||||||
|
#include <tqlabel.h>
|
||||||
|
#include <tqtimer.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
|
//#define PAM_GREETER_DEBUG
|
||||||
|
|
||||||
|
class KDMPasswordEdit : public KPasswordEdit {
|
||||||
|
public:
|
||||||
|
KDMPasswordEdit( TQWidget *parent ) : KPasswordEdit( parent, 0 ) {}
|
||||||
|
KDMPasswordEdit( KPasswordEdit::EchoModes echoMode, TQWidget *parent ) : KPasswordEdit( echoMode, parent, 0 ) {}
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent( TQContextMenuEvent * ) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
static FILE* log;
|
||||||
|
static void debug(const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list lst;
|
||||||
|
va_start(lst, fmt);
|
||||||
|
|
||||||
|
#ifdef PAM_GREETER_DEBUG
|
||||||
|
#if 0
|
||||||
|
vfprintf(log, fmt, lst);
|
||||||
|
fflush(log);
|
||||||
|
#else
|
||||||
|
char buf[6000];
|
||||||
|
sprintf(buf, "*** %s\n", fmt);
|
||||||
|
vsyslog(LOG_WARNING, buf, lst);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
va_end(lst);
|
||||||
|
}
|
||||||
|
|
||||||
|
static KPasswordEdit::EchoModes echoMode;
|
||||||
|
|
||||||
|
KPamGreeter::KPamGreeter( KGreeterPluginHandler *_handler,
|
||||||
|
KdmThemer *themer,
|
||||||
|
TQWidget *parent, TQWidget *pred,
|
||||||
|
const TQString &_fixedEntity,
|
||||||
|
Function _func, Context _ctx ) :
|
||||||
|
TQObject(),
|
||||||
|
KGreeterPlugin( _handler ),
|
||||||
|
fixedUser( _fixedEntity ),
|
||||||
|
func( _func ),
|
||||||
|
ctx( _ctx ),
|
||||||
|
exp( -1 ),
|
||||||
|
pExp( -1 ),
|
||||||
|
running( false )
|
||||||
|
{
|
||||||
|
ctx = Login;
|
||||||
|
|
||||||
|
debug("KPamGreeter constructed\n");
|
||||||
|
|
||||||
|
m_parentWidget = parent;
|
||||||
|
|
||||||
|
KdmItem *user_entry = 0, *pw_entry = 0;
|
||||||
|
int line = 0;
|
||||||
|
|
||||||
|
layoutItem = 0;
|
||||||
|
|
||||||
|
if (themer &&
|
||||||
|
(!(user_entry = themer->findNode( "user-entry" )) ||
|
||||||
|
!(pw_entry = themer->findNode( "pw-entry" ))))
|
||||||
|
themer = 0;
|
||||||
|
|
||||||
|
m_themer = themer;
|
||||||
|
|
||||||
|
if (!themer)
|
||||||
|
layoutItem = new TQGridLayout( 0, 0, 10 );
|
||||||
|
|
||||||
|
loginLabel = 0;
|
||||||
|
authLabel.clear();
|
||||||
|
authEdit.clear();
|
||||||
|
loginLabel = 0;
|
||||||
|
loginEdit = 0;
|
||||||
|
if (ctx == ExUnlock || ctx == ExChangeTok)
|
||||||
|
fixedUser = KUser().loginName();
|
||||||
|
if (func != ChAuthTok) {
|
||||||
|
debug("func != ChAuthTok\n");
|
||||||
|
debug("fixedUser: *%s*\n", fixedUser.latin1());
|
||||||
|
|
||||||
|
if (fixedUser.isEmpty()) {
|
||||||
|
loginEdit = new KLineEdit( parent );
|
||||||
|
loginEdit->setContextMenuEnabled( false );
|
||||||
|
connect( loginEdit, TQT_SIGNAL(lostFocus()), TQT_SLOT(slotLoginLostFocus()) );
|
||||||
|
connect( loginEdit, TQT_SIGNAL(lostFocus()), TQT_SLOT(slotActivity()) );
|
||||||
|
connect( loginEdit, TQT_SIGNAL(textChanged( const TQString & )), TQT_SLOT(slotActivity()) );
|
||||||
|
connect( loginEdit, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotActivity()) );
|
||||||
|
if (pred) {
|
||||||
|
parent->setTabOrder( pred, loginEdit );
|
||||||
|
pred = loginEdit;
|
||||||
|
}
|
||||||
|
if (!getLayoutItem()) {
|
||||||
|
loginEdit->adjustSize();
|
||||||
|
user_entry->setWidget( loginEdit );
|
||||||
|
} else {
|
||||||
|
loginLabel = new TQLabel( loginEdit, i18n("Username:"), parent );
|
||||||
|
getLayoutItem()->addWidget( loginLabel, line, 0 );
|
||||||
|
getLayoutItem()->addWidget( loginEdit, line++, 1 );
|
||||||
|
}
|
||||||
|
} else if (ctx != Login && ctx != Shutdown && getLayoutItem()) {
|
||||||
|
loginLabel = new TQLabel( i18n("Username:"), parent );
|
||||||
|
getLayoutItem()->addWidget( loginLabel, line, 0 );
|
||||||
|
getLayoutItem()->addWidget( new TQLabel( fixedUser, parent ), line++, 1 );
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
if (echoMode == -1)
|
||||||
|
passwdEdit = new KDMPasswordEdit( parent );
|
||||||
|
else
|
||||||
|
passwdEdit = new KDMPasswordEdit( echoMode,
|
||||||
|
parent );
|
||||||
|
connect( passwdEdit, TQT_SIGNAL(textChanged( const TQString & )),
|
||||||
|
TQT_SLOT(slotActivity()) );
|
||||||
|
connect( passwdEdit, TQT_SIGNAL(lostFocus()), TQT_SLOT(slotActivity()) );
|
||||||
|
if (pred) {
|
||||||
|
parent->setTabOrder( pred, passwdEdit );
|
||||||
|
pred = passwdEdit;
|
||||||
|
}
|
||||||
|
if (!getLayoutItem()) {
|
||||||
|
passwdEdit->adjustSize();
|
||||||
|
pw_entry->setWidget( passwdEdit );
|
||||||
|
} else {
|
||||||
|
passwdLabel = new TQLabel( passwdEdit,
|
||||||
|
func == Authenticate ?
|
||||||
|
i18n("hello &Password:") :
|
||||||
|
i18n("Current &password:"),
|
||||||
|
parent );
|
||||||
|
getLayoutItem()->addWidget( passwdLabel, line, 0 );
|
||||||
|
getLayoutItem()->addWidget( passwdEdit, line++, 1 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (loginEdit)
|
||||||
|
loginEdit->setFocus();
|
||||||
|
}
|
||||||
|
if (func != Authenticate) {
|
||||||
|
if (echoMode == -1) {
|
||||||
|
authEdit << new KDMPasswordEdit( echoMode, parent );
|
||||||
|
authEdit << new KDMPasswordEdit( echoMode, parent );
|
||||||
|
} else {
|
||||||
|
authEdit << new KDMPasswordEdit( parent );
|
||||||
|
authEdit << new KDMPasswordEdit( parent );
|
||||||
|
}
|
||||||
|
authLabel << new TQLabel( authEdit[0], i18n("&New password:"), parent );
|
||||||
|
authLabel << new TQLabel( authEdit[1], i18n("Con&firm password:"), parent );
|
||||||
|
if (pred) {
|
||||||
|
parent->setTabOrder( pred, authEdit[0] );
|
||||||
|
parent->setTabOrder( authEdit[0], authEdit[1] );
|
||||||
|
}
|
||||||
|
if (getLayoutItem()) {
|
||||||
|
getLayoutItem()->addWidget( authLabel[0], line, 0 );
|
||||||
|
getLayoutItem()->addWidget( authEdit[0], line++, 1 );
|
||||||
|
getLayoutItem()->addWidget( authLabel[1], line, 0 );
|
||||||
|
getLayoutItem()->addWidget( authEdit[1], line, 1 );
|
||||||
|
}
|
||||||
|
if (authEdit.size() >= 2)
|
||||||
|
authEdit[1]->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// virtual
|
||||||
|
KPamGreeter::~KPamGreeter()
|
||||||
|
{
|
||||||
|
debug("KPamGreeter::~KPamGreeter");
|
||||||
|
abort();
|
||||||
|
if (!layoutItem) {
|
||||||
|
delete loginEdit;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TQLayoutIterator it = static_cast<TQLayout *>(layoutItem)->iterator();
|
||||||
|
for (TQLayoutItem *itm = it.current(); itm; itm = ++it)
|
||||||
|
delete itm->widget();
|
||||||
|
delete layoutItem;
|
||||||
|
debug("destructor finished, good bye");
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::loadUsers( const TQStringList &users )
|
||||||
|
{
|
||||||
|
KCompletion *userNamesCompletion = new KCompletion;
|
||||||
|
userNamesCompletion->setItems( users );
|
||||||
|
loginEdit->setCompletionObject( userNamesCompletion );
|
||||||
|
loginEdit->setAutoDeleteCompletionObject( true );
|
||||||
|
loginEdit->setCompletionMode( KGlobalSettings::CompletionAuto );
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::presetEntity( const TQString &entity, int field )
|
||||||
|
{
|
||||||
|
debug("presetEntity(%s,%d) called!\n", entity.latin1(), field);
|
||||||
|
loginEdit->setText( entity );
|
||||||
|
if (field == 1 && authEdit.size() >= 1)
|
||||||
|
authEdit[0]->setFocus();
|
||||||
|
else {
|
||||||
|
loginEdit->setFocus();
|
||||||
|
loginEdit->selectAll();
|
||||||
|
if (field == -1 && authEdit.size() >= 1) {
|
||||||
|
authEdit[0]->setText( " " );
|
||||||
|
authEdit[0]->setEnabled( false );
|
||||||
|
authTok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curUser = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString // virtual
|
||||||
|
KPamGreeter::getEntity() const
|
||||||
|
{
|
||||||
|
return fixedUser.isEmpty() ? loginEdit->text() : fixedUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::setUser( const TQString &user )
|
||||||
|
{
|
||||||
|
// assert( fixedUser.isEmpty() );
|
||||||
|
curUser = user;
|
||||||
|
loginEdit->setText( user );
|
||||||
|
if (authEdit.size() >= 1) {
|
||||||
|
authEdit[0]->setFocus();
|
||||||
|
authEdit[0]->selectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::setEnabled(bool enable)
|
||||||
|
{
|
||||||
|
// assert( !passwd1Label );
|
||||||
|
// assert( func == Authenticate && ctx == Shutdown );
|
||||||
|
// if (loginLabel)
|
||||||
|
// loginLabel->setEnabled( enable );
|
||||||
|
authEdit[0]->setEnabled( enable );
|
||||||
|
setActive( enable );
|
||||||
|
if (enable)
|
||||||
|
authEdit[0]->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void // private
|
||||||
|
KPamGreeter::returnData()
|
||||||
|
{
|
||||||
|
debug("*************** returnData called with exp %d\n", exp);
|
||||||
|
|
||||||
|
|
||||||
|
switch (exp) {
|
||||||
|
case 0:
|
||||||
|
handler->gplugReturnText( (loginEdit ? loginEdit->text() :
|
||||||
|
fixedUser).local8Bit(),
|
||||||
|
KGreeterPluginHandler::IsUser );
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
handler->gplugReturnText( authEdit[0]->password(),
|
||||||
|
KGreeterPluginHandler::IsPassword |
|
||||||
|
KGreeterPluginHandler::IsSecret );
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
handler->gplugReturnText( authEdit[1]->password(),
|
||||||
|
KGreeterPluginHandler::IsSecret );
|
||||||
|
break;
|
||||||
|
default: // case 3:
|
||||||
|
handler->gplugReturnText( authEdit[2]->password(),
|
||||||
|
KGreeterPluginHandler::IsNewPassword |
|
||||||
|
KGreeterPluginHandler::IsSecret );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool // virtual
|
||||||
|
KPamGreeter::textMessage( const char *text, bool err )
|
||||||
|
{
|
||||||
|
debug(" ************** textMessage(%s, %d)\n", text, err);
|
||||||
|
|
||||||
|
if (!authEdit.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (getLayoutItem()) {
|
||||||
|
TQLabel* label = new TQLabel(TQString::fromUtf8(text), m_parentWidget);
|
||||||
|
getLayoutItem()->addWidget(label, state+1, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking )
|
||||||
|
{
|
||||||
|
debug("textPrompt called with prompt %s echo %d nonBlocking %d", prompt, echo, nonBlocking);
|
||||||
|
debug("state is %d, authEdit.size is %d\n", state, authEdit.size());
|
||||||
|
|
||||||
|
if (state == 0 && echo) {
|
||||||
|
if (loginLabel)
|
||||||
|
loginLabel->setText(TQString::fromUtf8(prompt));
|
||||||
|
else if (m_themer) {
|
||||||
|
KdmLabel *kdmlabel = static_cast<KdmLabel*>(m_themer->findNode("user-label"));
|
||||||
|
if (kdmlabel) {
|
||||||
|
//userLabel->setText(TQString::fromUtf8(prompt));
|
||||||
|
kdmlabel->label.text = TQString::fromUtf8(prompt);
|
||||||
|
TQTimer::singleShot(0, kdmlabel, TQT_SLOT(update()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (state >= authEdit.size()) {
|
||||||
|
if (getLayoutItem()) {
|
||||||
|
TQLabel* label = new TQLabel(TQString::fromUtf8(prompt), m_parentWidget);
|
||||||
|
getLayoutItem()->addWidget(label, state+1, 0, 0);
|
||||||
|
debug("added label widget to layout");
|
||||||
|
}
|
||||||
|
else if (m_themer) {
|
||||||
|
debug("themer found!");
|
||||||
|
KdmItem *pw_label = 0;
|
||||||
|
|
||||||
|
KdmLabel *kdmlabel = static_cast<KdmLabel*>(m_themer->findNode("pw-label"));
|
||||||
|
if (kdmlabel) {
|
||||||
|
//userLabel->setText(TQString::fromUtf8(prompt));
|
||||||
|
TQString str = TQString::fromUtf8(prompt);
|
||||||
|
kdmlabel->label.text = str;
|
||||||
|
TQTimer::singleShot(0, kdmlabel, TQT_SLOT(update()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KDMPasswordEdit* passwdEdit;
|
||||||
|
|
||||||
|
if (echoMode == -1)
|
||||||
|
passwdEdit = new KDMPasswordEdit( m_parentWidget );
|
||||||
|
else
|
||||||
|
passwdEdit = new KDMPasswordEdit( echoMode, m_parentWidget);
|
||||||
|
connect( passwdEdit, TQT_SIGNAL(textChanged( const TQString & )),
|
||||||
|
TQT_SLOT(slotActivity()) );
|
||||||
|
connect( passwdEdit, TQT_SIGNAL(lostFocus()), TQT_SLOT(slotActivity()) );
|
||||||
|
authEdit << passwdEdit;
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
for(TQValueList<KPasswordEdit*>::iterator it = authEdit.begin();
|
||||||
|
it != authEdit.end();
|
||||||
|
++it) {
|
||||||
|
if ((*it)->isEnabled() && (*it)->text().isEmpty()) {
|
||||||
|
(*it)->setFocus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (getLayoutItem())
|
||||||
|
getLayoutItem()->addWidget(passwdEdit, state+1, 1, 0);
|
||||||
|
|
||||||
|
if (m_themer) {
|
||||||
|
debug("themer found!");
|
||||||
|
KdmItem *pw_entry = 0;
|
||||||
|
|
||||||
|
pw_entry = m_themer->findNode("pw-entry");
|
||||||
|
|
||||||
|
if (pw_entry && passwdEdit)
|
||||||
|
pw_entry->setWidget(passwdEdit);
|
||||||
|
|
||||||
|
if (0) {
|
||||||
|
//userLabel->setText(TQString::fromUtf8(prompt));
|
||||||
|
//kdmlabel->label.text = TQString::fromUtf8(prompt);
|
||||||
|
//TQTimer::singleShot(0, kdmlabel, TQT_SLOT(update()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
debug("no themer found!");
|
||||||
|
}
|
||||||
|
++state;
|
||||||
|
pExp = exp;
|
||||||
|
|
||||||
|
exp = authEdit.size();
|
||||||
|
debug("state %d exp: %d, has %d\n", state, exp, has);
|
||||||
|
|
||||||
|
if (has >= exp || nonBlocking)
|
||||||
|
returnData();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool // virtual
|
||||||
|
KPamGreeter::binaryPrompt( const char *, bool )
|
||||||
|
{
|
||||||
|
// this simply cannot happen ... :}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::start()
|
||||||
|
{
|
||||||
|
debug("******* start() called\n");
|
||||||
|
|
||||||
|
while(authEdit.begin() != authEdit.end()) {
|
||||||
|
KPasswordEdit* item = *authEdit.remove(authEdit.begin());
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(authLabel.begin() != authLabel.end()) {
|
||||||
|
TQLabel* item = *authLabel.remove(authLabel.begin());
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
authTok = !(authEdit.size() >= 2 && authEdit[1]->isEnabled());
|
||||||
|
exp = has = -1;
|
||||||
|
state = 0;
|
||||||
|
running = true;
|
||||||
|
handler->gplugStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::suspend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::resume()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::next()
|
||||||
|
{
|
||||||
|
debug("********* next() called state %d\n", state);
|
||||||
|
|
||||||
|
if (state == 0 && running && handler) {
|
||||||
|
debug(" **** returned text!\n");
|
||||||
|
handler->gplugReturnText( (loginEdit ? loginEdit->text() :
|
||||||
|
fixedUser).local8Bit(),
|
||||||
|
KGreeterPluginHandler::IsUser );
|
||||||
|
setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
has = 0;
|
||||||
|
|
||||||
|
for(TQValueList<KPasswordEdit*>::iterator it = authEdit.begin();
|
||||||
|
it != authEdit.end();
|
||||||
|
++it) {
|
||||||
|
|
||||||
|
has++;
|
||||||
|
if ((*it)->hasFocus()) {
|
||||||
|
++it;
|
||||||
|
if (it != authEdit.end())
|
||||||
|
(*it)->setFocus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (it == authEdit.end())
|
||||||
|
has = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug(" has %d and exp %d\n", has, exp);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// assert( running );
|
||||||
|
if (loginEdit && loginEdit->hasFocus()) {
|
||||||
|
passwdEdit->setFocus(); // will cancel running login if necessary
|
||||||
|
has = 0;
|
||||||
|
} else if (passwdEdit && passwdEdit->hasFocus()) {
|
||||||
|
if (passwd1Edit)
|
||||||
|
passwd1Edit->setFocus();
|
||||||
|
has = 1;
|
||||||
|
} else if (passwd1Edit) {
|
||||||
|
if (passwd1Edit->hasFocus()) {
|
||||||
|
passwd2Edit->setFocus();
|
||||||
|
has = 1; // sic!
|
||||||
|
} else
|
||||||
|
has = 3;
|
||||||
|
} else
|
||||||
|
has = 1;
|
||||||
|
if (exp < 0)
|
||||||
|
handler->gplugStart();
|
||||||
|
#endif
|
||||||
|
if (has >= exp)
|
||||||
|
returnData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::abort()
|
||||||
|
{
|
||||||
|
debug("***** abort() called\n");
|
||||||
|
|
||||||
|
running = false;
|
||||||
|
if (exp >= 0) {
|
||||||
|
exp = -1;
|
||||||
|
handler->gplugReturnText( 0, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::succeeded()
|
||||||
|
{
|
||||||
|
debug("**** succeeded() called\n");
|
||||||
|
|
||||||
|
// assert( running || timed_login );
|
||||||
|
if (!authTok)
|
||||||
|
setActive( false );
|
||||||
|
else
|
||||||
|
setAllActive( false );
|
||||||
|
exp = -1;
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::failed()
|
||||||
|
{
|
||||||
|
// assert( running || timed_login );
|
||||||
|
setActive( false );
|
||||||
|
setAllActive( false );
|
||||||
|
exp = -1;
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include<assert.h>
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::revive()
|
||||||
|
{
|
||||||
|
// assert( !running );
|
||||||
|
setAllActive( true );
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
if (authEdit.size() < 1)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
assert(authEdit.size() >= 1);
|
||||||
|
if (authTok) {
|
||||||
|
authEdit[0]->erase();
|
||||||
|
if(authEdit.size() >= 2)
|
||||||
|
authEdit[1]->erase();
|
||||||
|
authEdit[0]->setFocus();
|
||||||
|
} else {
|
||||||
|
authEdit[0]->erase();
|
||||||
|
if (loginEdit && loginEdit->isEnabled())
|
||||||
|
authEdit[0]->setEnabled( true );
|
||||||
|
else {
|
||||||
|
setActive( true );
|
||||||
|
if (loginEdit && loginEdit->text().isEmpty())
|
||||||
|
loginEdit->setFocus();
|
||||||
|
else
|
||||||
|
authEdit[0]->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void // virtual
|
||||||
|
KPamGreeter::clear()
|
||||||
|
{
|
||||||
|
// assert( !running && !passwd1Edit );
|
||||||
|
authEdit[0]->erase();
|
||||||
|
if (loginEdit) {
|
||||||
|
loginEdit->clear();
|
||||||
|
loginEdit->setFocus();
|
||||||
|
curUser = TQString::null;
|
||||||
|
} else
|
||||||
|
authEdit[0]->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private
|
||||||
|
|
||||||
|
void
|
||||||
|
KPamGreeter::setActive( bool enable )
|
||||||
|
{
|
||||||
|
if (loginEdit)
|
||||||
|
loginEdit->setEnabled( enable );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KPamGreeter::setAllActive( bool enable )
|
||||||
|
{
|
||||||
|
for(TQValueList<KPasswordEdit*>::iterator it = authEdit.begin();
|
||||||
|
it != authEdit.end();
|
||||||
|
++it)
|
||||||
|
(*it)->setEnabled( enable );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KPamGreeter::slotLoginLostFocus()
|
||||||
|
{
|
||||||
|
if (!running)
|
||||||
|
return;
|
||||||
|
if (exp > 0) {
|
||||||
|
if (curUser == loginEdit->text())
|
||||||
|
return;
|
||||||
|
exp = -1;
|
||||||
|
handler->gplugReturnText( 0, 0 );
|
||||||
|
}
|
||||||
|
curUser = loginEdit->text();
|
||||||
|
debug("curUser is %s", curUser.latin1());
|
||||||
|
handler->gplugSetUser( curUser );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KPamGreeter::slotActivity()
|
||||||
|
{
|
||||||
|
debug("slotActivity");
|
||||||
|
|
||||||
|
if (running)
|
||||||
|
handler->gplugActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
// factory
|
||||||
|
|
||||||
|
static bool init( const TQString &,
|
||||||
|
TQVariant (*getConf)( void *, const char *, const TQVariant & ),
|
||||||
|
void *ctx )
|
||||||
|
{
|
||||||
|
echoMode = (KPasswordEdit::EchoModes) getConf( ctx, "EchoMode", TQVariant( -1 ) ).toInt();
|
||||||
|
KGlobal::locale()->insertCatalogue( "kgreet_pam" );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void done( void )
|
||||||
|
{
|
||||||
|
KGlobal::locale()->removeCatalogue( "kgreet_pam" );
|
||||||
|
if (log && log != stderr)
|
||||||
|
fclose(log);
|
||||||
|
log = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static KGreeterPlugin *
|
||||||
|
create( KGreeterPluginHandler *handler, KdmThemer *themer,
|
||||||
|
TQWidget *parent, TQWidget *predecessor,
|
||||||
|
const TQString &fixedEntity,
|
||||||
|
KGreeterPlugin::Function func,
|
||||||
|
KGreeterPlugin::Context ctx )
|
||||||
|
{
|
||||||
|
return new KPamGreeter( handler, themer, parent, predecessor, fixedEntity, func, ctx );
|
||||||
|
}
|
||||||
|
|
||||||
|
KDE_EXPORT kgreeterplugin_info kgreeterplugin_info = {
|
||||||
|
I18N_NOOP("Pam conversation plugin"), "pam",
|
||||||
|
kgreeterplugin_info::Local | kgreeterplugin_info::Presettable,
|
||||||
|
init, done, create
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "kgreet_pam.moc"
|
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Conversation widget for kdm greeter
|
||||||
|
|
||||||
|
Copyright (C) 2008 Dirk Mueller <mueller@kde.org>
|
||||||
|
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef KGREET_CLASSIC_H
|
||||||
|
#define KGREET_CLASSIC_H
|
||||||
|
|
||||||
|
#include "kgreeterplugin.h"
|
||||||
|
|
||||||
|
#include <tqobject.h>
|
||||||
|
#include <tqlayout.h>
|
||||||
|
|
||||||
|
class KLineEdit;
|
||||||
|
class KPasswordEdit;
|
||||||
|
class KSimpleConfig;
|
||||||
|
class TQGridLayout;
|
||||||
|
class TQLabel;
|
||||||
|
|
||||||
|
class KPamGreeter : public TQObject, public KGreeterPlugin {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KPamGreeter( KGreeterPluginHandler *handler,
|
||||||
|
KdmThemer *themer,
|
||||||
|
TQWidget *parent, TQWidget *predecessor,
|
||||||
|
const TQString &fixedEntitiy,
|
||||||
|
Function func, Context ctx );
|
||||||
|
~KPamGreeter();
|
||||||
|
virtual void loadUsers( const TQStringList &users );
|
||||||
|
virtual void presetEntity( const TQString &entity, int field );
|
||||||
|
virtual TQString getEntity() const;
|
||||||
|
virtual void setUser( const TQString &user );
|
||||||
|
virtual void setEnabled( bool on );
|
||||||
|
virtual bool textMessage( const char *message, bool error );
|
||||||
|
virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking );
|
||||||
|
virtual bool binaryPrompt( const char *prompt, bool nonBlocking );
|
||||||
|
virtual void start();
|
||||||
|
virtual void suspend();
|
||||||
|
virtual void resume();
|
||||||
|
virtual void next();
|
||||||
|
virtual void abort();
|
||||||
|
virtual void succeeded();
|
||||||
|
virtual void failed();
|
||||||
|
virtual void revive();
|
||||||
|
virtual void clear();
|
||||||
|
|
||||||
|
TQGridLayout *getLayoutItem() const { return static_cast<TQGridLayout*>(layoutItem); }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slotLoginLostFocus();
|
||||||
|
void slotActivity();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setActive( bool enable );
|
||||||
|
void setAllActive( bool enable );
|
||||||
|
void returnData();
|
||||||
|
|
||||||
|
TQLabel *loginLabel;
|
||||||
|
TQValueList<TQLabel*> authLabel;
|
||||||
|
KLineEdit *loginEdit;
|
||||||
|
TQWidget* m_parentWidget;
|
||||||
|
TQValueList<KPasswordEdit*> authEdit;
|
||||||
|
KSimpleConfig *stsFile;
|
||||||
|
KdmThemer *m_themer;
|
||||||
|
TQString fixedUser, curUser;
|
||||||
|
Function func;
|
||||||
|
Context ctx;
|
||||||
|
int exp, pExp, has;
|
||||||
|
unsigned state;
|
||||||
|
bool running, authTok;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* KGREET_CLASSIC_H */
|
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
# vim:sw=4:et
|
||||||
|
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub getKDEDocDir()
|
||||||
|
{
|
||||||
|
my $prefix = `kde-config --prefix`;
|
||||||
|
chomp $prefix;
|
||||||
|
|
||||||
|
$prefix = "/opt/kde" if (not defined($prefix));
|
||||||
|
return "$prefix/share/doc";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub addRoot()
|
||||||
|
{
|
||||||
|
my $kdedocdir = &getKDEDocDir;
|
||||||
|
|
||||||
|
open (IN, "-|") || exec "beagle-config", "indexing", "ListRoots";
|
||||||
|
|
||||||
|
my $kdedoc_found = 0;
|
||||||
|
while(<IN>) {
|
||||||
|
if (/^$kdedocdir/o) {
|
||||||
|
$kdedoc_found = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(IN);
|
||||||
|
|
||||||
|
if (not $kdedoc_found) {
|
||||||
|
`beagle-config indexing AddRoot $kdedocdir`;
|
||||||
|
`beagle-config indexing AddRoot $kdedocdir-bundle`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub createExistsFile($$)
|
||||||
|
{
|
||||||
|
my ($idir, $ident) = @_;
|
||||||
|
|
||||||
|
open(OUT, ">", "$idir/$idir");
|
||||||
|
close(OUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $idir = $ARGV[0];
|
||||||
|
my $ident = $ARGV[1];
|
||||||
|
|
||||||
|
if (addRoot) {
|
||||||
|
createExistsFile($idir, $ident);
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
# vim:sw=4:et
|
||||||
|
|
||||||
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
use Getopt::Long;
|
||||||
|
|
||||||
|
sub isBeagleRunning()
|
||||||
|
{
|
||||||
|
open(IN, "-|") || exec "beagle-ping";
|
||||||
|
while(<IN>) {
|
||||||
|
if (/^Daemon version:/) {
|
||||||
|
close(IN);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(IN);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub formatHTML($$)
|
||||||
|
{
|
||||||
|
my ($query, $hits) = @_;
|
||||||
|
|
||||||
|
print "<html>\n<body\n<ul>\n";
|
||||||
|
|
||||||
|
foreach my $hit(@$hits) {
|
||||||
|
print "<li>$hit</li>\n";
|
||||||
|
}
|
||||||
|
print "</ul>\n</body>\n</html>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub beagleQuery($$$)
|
||||||
|
{
|
||||||
|
my ($words, $method, $maxnum) = @_;
|
||||||
|
|
||||||
|
my @hits = ();
|
||||||
|
|
||||||
|
open(IN, "-|") || exec "beagle-query", "--type", "DocbookEntry", "--type", "File", "--max-hits", $maxnum, @$words, "ext:docbook";
|
||||||
|
while(<IN>) {
|
||||||
|
chop;
|
||||||
|
next if (/^Debug:/);
|
||||||
|
|
||||||
|
my $uri = $_;
|
||||||
|
$uri = $1 if ($uri =~ /^file:\/\/(.*)$/);
|
||||||
|
|
||||||
|
print "uri: $uri\n";
|
||||||
|
my $helpLink = &makeHelpLink($uri);
|
||||||
|
|
||||||
|
push(@hits, $helpLink) if (!grep { /^$helpLink$/ } @hits);
|
||||||
|
}
|
||||||
|
close(IN);
|
||||||
|
return @hits;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub makeHelpLink($)
|
||||||
|
{
|
||||||
|
# Try to figure out the name of the application from the path to its index.docbook file
|
||||||
|
|
||||||
|
my ($path) = @_;
|
||||||
|
my @pathcomponents = split '/', $path;
|
||||||
|
|
||||||
|
my $appName = $pathcomponents[-2];
|
||||||
|
my $appName2 = $pathcomponents[-3];
|
||||||
|
|
||||||
|
if ($appName eq $appName2 or $appName2 eq "doc"
|
||||||
|
or (-d "/usr/share/locale/$appName2")) {
|
||||||
|
return "<a href=\"help:/$appName\">$appName</a>";
|
||||||
|
}
|
||||||
|
return "<a href=\"help:/$appName2/$appName\">$appName ($appName2)</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $method = "and";
|
||||||
|
my $maxnum = 100;
|
||||||
|
|
||||||
|
GetOptions("method=s", \$method, "maxnum=i", \$maxnum);
|
||||||
|
|
||||||
|
my @hits = ("The Beagle daemon is not running, search is not available");
|
||||||
|
|
||||||
|
my @words = @ARGV;
|
||||||
|
|
||||||
|
if (isBeagleRunning()) {
|
||||||
|
@hits = beagleQuery(\@words, $method, $maxnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@hits = ("There are no search results") if ($#hits < 0);
|
||||||
|
|
||||||
|
formatHTML(\@words, \@hits);
|
After Width: | Height: | Size: 213 B |
After Width: | Height: | Size: 255 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 214 B |
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 834 B |
After Width: | Height: | Size: 865 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 781 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 174 B |
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 211 B |
After Width: | Height: | Size: 218 B |
After Width: | Height: | Size: 176 B |
After Width: | Height: | Size: 202 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 217 B |
After Width: | Height: | Size: 722 B |
After Width: | Height: | Size: 181 B |
After Width: | Height: | Size: 218 B |
After Width: | Height: | Size: 170 B |
After Width: | Height: | Size: 398 B |
After Width: | Height: | Size: 417 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 304 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 351 B |
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 175 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 256 B |
After Width: | Height: | Size: 198 B |
After Width: | Height: | Size: 327 B |
After Width: | Height: | Size: 198 B |
@ -0,0 +1,352 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>TimedLogoutDlg</class>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>TimedLogoutDlg</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>381</width>
|
||||||
|
<height>131</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Confirmation</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QFrame">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>frame3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>Raised</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="midLineWidth">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout10</cstring>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout8</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout6</cstring>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer3_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>MinimumExpanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>2</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_logo</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>1</hsizetype>
|
||||||
|
<vsizetype>1</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>48</width>
|
||||||
|
<height>48</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>MinimumExpanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>2</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout7</cstring>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_title</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>7</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<bold>1</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Would you like to shutdown your computer?</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>PlainText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>AlignVCenter|AlignLeft</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_text</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>7</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>If you do not act, your computer will shutdown
|
||||||
|
after X automatically.</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>RichText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>WordBreak|AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer4</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>30</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout9</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>90</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>pushButton1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Confirm</string>
|
||||||
|
</property>
|
||||||
|
<property name="on">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer2_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>90</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>pushButton2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>1</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer2_2_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>90</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>pushButton1</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>TimedLogoutDlg</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>pushButton2</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>TimedLogoutDlg</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|