In preparation for move to kdebase:

* Small usability stuff
* Make it a unique app
* Make it possible to run kdepasswd USER when user is USER
* Exclude the userinfo KCM and clean the Makefile.am
* Use KUser.

svn path=/trunk/kdeutils/kdepasswd/; revision=289013
This commit is contained in:
Frans Englich 2004-02-18 14:15:59 +00:00
parent 4a3d46a052
commit 35053e89cf
4 changed files with 38 additions and 36 deletions

View file

@ -1,23 +1,15 @@
## Makefile.am for kdepasswd
SUBDIRS = . userinfo
INCLUDES= $(all_includes)
## kdepasswd
## Abstract away the dialogs so that userinfo can use them.
noinst_LTLIBRARIES = libpassdialogs.la
libpassdialogs_la_SOURCES = passwd.cpp passwddlg.cpp
libpassdialogs_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
bin_PROGRAMS = kdepasswd
kdepasswd_SOURCES = kdepasswd.cpp
kdepasswd_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kdepasswd_LDADD = libpassdialogs.la $(LIB_KDEUI) -lkdesu
kdepasswd_SOURCES = kdepasswd.cpp passwd.cpp passwddlg.cpp
kdepasswd_LDFLAGS = $(all_libraries)
kdepasswd_LDADD = $(LIB_KDEUI) $(LIB_KIO)
METASOURCES = AUTO
AM_CPPFLAGS= $(all_includes)
noinst_HEADERS = passwd.h passwddlg.h
xdg_apps_DATA = kdepasswd.desktop
## Messages
messages:
$(XGETTEXT) $(kdepasswd_SOURCES) $(libpassdialogs_la_SOURCES) -o $(podir)/kdepasswd.pot
$(XGETTEXT) $(kdepasswd_SOURCES) -o $(podir)/kdepasswd.pot

View file

@ -7,15 +7,14 @@
*/
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <kapplication.h>
#include <kuniqueapplication.h>
#include <klocale.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kmessagebox.h>
#include <kuser.h>
#include <kdebug.h>
#include "passwd.h"
#include "passwddlg.h"
@ -37,16 +36,26 @@ int main(int argc, char **argv)
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::addCmdLineOptions(options);
KUniqueApplication::addCmdLineOptions();
if (!KUniqueApplication::start()) {
kdDebug() << "kdepasswd is already running" << endl;
return 0;
}
KUniqueApplication app;
KUser ku;
QCString user;
bool bRoot = ku.isSuperUser();
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KApplication app;
bool bRoot = (getuid() == 0);
QCString user;
if (args->count())
user = args->arg(0);
if (!user.isEmpty() && !bRoot)
/* You must be able to run "kdepasswd loginName" */
if ( !user.isEmpty() && user!=KUser().loginName().utf8() && !bRoot)
{
KMessageBox::sorry(0, i18n("You need to be root to change the password of other users."));
return 0;
@ -57,10 +66,12 @@ int main(int argc, char **argv)
{
int result = KDEpasswd1Dialog::getPassword(oldpass);
if (result != KDEpasswd1Dialog::Accepted)
exit(0);
return 0;
}
KDEpasswd2Dialog *dlg = new KDEpasswd2Dialog(oldpass, user);
dlg->exec();
return 0;

View file

@ -1,5 +1,12 @@
[Desktop Entry]
Encoding=UTF-8
Exec=kdepasswd
Icon=password
Type=Application
NoDisplay=true
Categories=Qt;KDE;Settings
NoDisplay=true
X-DCOP-ServiceType=Unique
Name=Change Password
Name[af]=Verander Wagwoord
Name[ar]=تغيير كلمة السر
@ -45,14 +52,6 @@ Name[uz]=Махфий сўзни ўзгартириш
Name[wa]=Candjî l' sicret
Name[xh]=Tshintsha Igama eliyimfihlo
Name[xx]=xxChange Passwordxx
Name[zh_CN]=
Name[zh_CN]=
Name[zh_TW]=
Name[zu]=Shintsha Igama-lokudlula
Exec=kdepasswd
TerminalOptions=
Icon=password
Type=Application
Terminal=0
X-KDE-StartupNotify=true
X-DCOP-ServiceType=Multi
Categories=Qt;KDE;Settings

View file

@ -17,7 +17,7 @@ KDEpasswd1Dialog::KDEpasswd1Dialog()
: KPasswordDialog(Password, false, 0)
{
setCaption(i18n("Change Password"));
setPrompt(i18n("Please enter your current password."));
setPrompt(i18n("Please enter your current password:"));
}
@ -86,9 +86,9 @@ KDEpasswd2Dialog::KDEpasswd2Dialog(const char *oldpass, QCString user)
setCaption(i18n("Change Password"));
if (m_User.isEmpty())
setPrompt(i18n("Please enter your new password."));
setPrompt(i18n("Please enter your new password:"));
else
setPrompt(i18n("Please enter the new password for user <b>%1</b>.").arg(m_User));
setPrompt(i18n("Please enter the new password for user <b>%1</b>:").arg(m_User));
}