Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / apps / kdepasswd / kdepasswd.cpp
blobed4788dc183f4f0644eaaee9ce0bd22b0721d6b1
1 /* vi: ts=8 sts=4 sw=4
3 * This file is part of the KDE project, module kdesu.
4 * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
6 Permission to use, copy, modify, and distribute this software
7 and its documentation for any purpose and without fee is hereby
8 granted, provided that the above copyright notice appear in all
9 copies and that both that the copyright notice and this
10 permission notice and warranty disclaimer appear in supporting
11 documentation, and that the name of the author not be used in
12 advertising or publicity pertaining to distribution of the
13 software without specific, written prior permission.
15 The author disclaim all warranties with regard to this
16 software, including all implied warranties of merchantability
17 and fitness. In no event shall the author be liable for any
18 special, indirect or consequential damages or any damages
19 whatsoever resulting from loss of use, data or profits, whether
20 in an action of contract, negligence or other tortious action,
21 arising out of or in connection with the use or performance of
22 this software.
26 #include <kdeversion.h>
27 #include <kuniqueapplication.h>
28 #include <klocale.h>
29 #include <kaboutdata.h>
30 #include <kcmdlineargs.h>
31 #include <kmessagebox.h>
32 #include <kuser.h>
33 #include <kdebug.h>
35 #include "passwd.h"
36 #include "passwddlg.h"
39 int main(int argc, char **argv)
41 KAboutData aboutData("kdepasswd", 0, ki18n("KDE passwd"),
42 KDE_VERSION_STRING, ki18n("Changes a UNIX password."),
43 KAboutData::License_Artistic, ki18n("Copyright (c) 2000 Geert Jansen"));
44 aboutData.addAuthor(ki18n("Geert Jansen"), ki18n("Maintainer"),
45 "jansen@kde.org");
47 KCmdLineArgs::init(argc, argv, &aboutData);
49 KCmdLineOptions options;
50 options.add("+[user]", ki18n("Change password of this user"));
51 KCmdLineArgs::addCmdLineOptions(options);
52 KUniqueApplication::addCmdLineOptions();
55 if (!KUniqueApplication::start()) {
56 kDebug() << "kdepasswd is already running";
57 return 0;
60 KUniqueApplication app;
61 QApplication::setWindowIcon( KIcon( "preferences-desktop-user-password" ) );
63 KUser ku;
64 QString user;
65 bool bRoot = ku.isSuperUser();
66 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
68 if (args->count())
69 user = args->arg(0);
71 /* You must be able to run "kdepasswd loginName" */
72 if ( !user.isEmpty() && user!=KUser().loginName() && !bRoot)
74 KMessageBox::sorry(0, i18n("You need to be root to change the password of other users."));
75 return 0;
78 QByteArray oldpass;
79 if (!bRoot)
81 int result = KDEpasswd1Dialog::getPassword(oldpass);
82 if (result != KDEpasswd1Dialog::Accepted)
83 return 0;
86 KDEpasswd2Dialog *dlg = new KDEpasswd2Dialog(oldpass, user.toLocal8Bit());
89 dlg->exec();
91 return 0;