Debian Codegraph @

cvsservice/cvsaskpass.cpp

raw symbols SCIP
1 /*
2 * Copyright (c) 2003 Christian Loose <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21 #include <QApplication>
22 #include <QCommandLineParser>
23 #include <QRegExp>
24
25 #include <KLocalizedString>
26 #include <KPasswordDialog>
27 #include <kaboutdata.h>
28
29 #include <iostream>
30
31 #include "../cervisia_version.h"
32
33 int main(int argc, char **argv)
34 {
35 KLocalizedString::setApplicationDomain("cervisia");
36
37 KAboutData about("cvsaskpass",
38 i18n("cvsaskpass"),
39 CERVISIA_VERSION_STRING,
40 i18n("ssh-askpass for the CVS D-Bus Service"),
41 KAboutLicense::LGPL,
42 i18n("Copyright (c) 2003 Christian Loose"));
43
44 KAboutData::setApplicationData(about);
45
46 QApplication app(argc, argv);
47
48 QCommandLineParser parser;
49 parser.addPositionalArgument(QLatin1String("prompt"), i18n("prompt"), QLatin1String("[prompt]"));
50
51 parser.process(app);
52
53 if (!parser.positionalArguments().count())
54 return 1;
55
56 // parse repository name from the passed argument
57 QString prompt = parser.positionalArguments()[0];
58 QRegExp rx("(.*@.*)'s password:");
59
60 KPasswordDialog dlg;
61 dlg.setPrompt(i18n("Please type in your password below."));
62 // dlg.setWindowTitle(i18n("Enter Password"));
63
64 if (prompt.contains(rx))
65 dlg.addCommentLine(i18n("Repository:"), rx.cap(1));
66
67 int res = dlg.exec();
68 if (res == KPasswordDialog::Accepted) {
69 std::cout << dlg.password().toUtf8().constData() << std::endl;
70 return 0;
71 }
72
73 return 1;
74 }