Proof-reading.
[kdetoys.git] / kweather / reportmain.cpp
blob7bcc56dfe2edc9b0db716dcdadb145ed8d2c8b8c
1 /***************************************************************************
2 * *
3 * Copyright (C) 2002-2003 Ian Reinhart Geiser <geiseri@kde.org> *
4 * Copyright (C) 2002-2003 Nadeem Hasan <nhasan@kde.org> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
22 #include "reportview.h"
24 #include <stdlib.h>
25 #include <kcmdlineargs.h>
26 #include <kdebug.h>
27 #include <kapplication.h>
28 #include <kaboutdata.h>
29 #include <kglobal.h>
30 #include <klocale.h>
31 #include <ktoolinvocation.h>
33 #include <QtDBus/QDBusConnection>
34 #include <QtDBus/QDBusConnectionInterface>
36 extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
38 KAboutData aboutData("reportview", 0, ki18n("Weather Report"),
39 "0.8", ki18n("Weather Report for KWeatherService"),
40 KAboutData::License_GPL, ki18n("(C) 2002-2003, Ian Reinhart Geiser"));
41 aboutData.addAuthor(ki18n("Ian Reinhart Geiser"), ki18n("Developer"),
42 "geiseri@kde.org");
43 aboutData.addAuthor(ki18n("Nadeem Hasan"), ki18n("Developer"),
44 "nhasan@kde.org");
46 KGlobal::locale()->setMainCatalog( "kweather" );
48 KCmdLineArgs::init( argc, argv, &aboutData );
50 KCmdLineOptions options;
51 options.add("+location", ki18n( "METAR location code for the report" ));
52 KCmdLineArgs::addCmdLineOptions( options );
53 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
55 if ( args->count() != 1 )
57 args->usage();
58 return -1;
61 KApplication app;
63 QString error;
64 if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.KWeatherService"))
66 if (KToolInvocation::startServiceByDesktopName("kweatherservice",
67 QStringList(), &error))
69 kDebug() << "Starting kweatherservice failed: " << error;
70 return -2;
74 QString reportLocation = args->arg( 0 );
75 args->clear();
76 reportView *report = new reportView(reportLocation);
78 report->exec();
80 delete report;
82 return 0;