2 * Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include <QDBusInterface>
22 #include <KCmdLineArgs>
25 int main(int argc
, char* argv
[])
27 KAboutData
aboutData( "kquitapp", 0, ki18n("Command line application quitter"),
28 "1.0", ki18n("Quit a D-Bus enabled application easily"), KAboutData::License_GPL
,
29 ki18n("(c) 2006, Aaron Seigo") );
30 aboutData
.addAuthor(ki18n("Aaron J. Seigo"), ki18n("Current maintainer"), "aseigo@kde.org");
31 KCmdLineArgs::init(argc
, argv
, &aboutData
);
33 KCmdLineOptions options
;
34 options
.add("service", ki18n("Full service name, overrides application name provided"));
35 options
.add("path <path>", ki18n("Path in the D-Bus interface to use"), "/MainApplication");
36 options
.add("+application", ki18n("The name of the application to quit"));
37 KCmdLineArgs::addCmdLineOptions(options
);
38 KCmdLineArgs
* args
= KCmdLineArgs::parsedArgs();
40 if (args
->count() == 0)
46 if (args
->isSet("service"))
48 service
= args
->getOption("service");
52 service
= QString("org.kde.%1").arg(QString(args
->arg(0)));
55 QString
path("/MainApplication");
56 if (args
->isSet("path"))
58 path
= args
->getOption("path");
61 QDBusInterface
interface(service
, path
);
62 interface
.call("quit");