1 | /* |
2 | Copyright (c) 2009 Volker Krause <vkrause@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "dialog.h" |
21 | #include "global.h" |
22 | |
23 | #include <akonadi/control.h> |
24 | |
25 | #include <kaboutdata.h> |
26 | #include <kapplication.h> |
27 | #include <kcmdlineargs.h> |
28 | #include <kglobal.h> |
29 | #include <KUniqueApplication> |
30 | |
31 | |
32 | #include <stdio.h> |
33 | |
34 | int main( int argc, char **argv ) |
35 | { |
36 | KAboutData aboutData( "accountwizard" , 0, |
37 | ki18n( "Account Assistant" ), |
38 | "0.1" , |
39 | ki18n( "Helps setting up PIM accounts" ), |
40 | KAboutData::License_LGPL, |
41 | ki18n( "(c) 2009 the Akonadi developers" ), |
42 | KLocalizedString(), |
43 | "http://pim.kde.org/akonadi/" ); |
44 | aboutData.setProgramIconName( QLatin1String("akonadi" ) ); |
45 | aboutData.addAuthor( ki18n( "Volker Krause" ), ki18n( "Author" ), "vkrause@kde.org" ); |
46 | aboutData.addAuthor( ki18n( "Laurent Montel" ), KLocalizedString() , "montel@kde.org" ); |
47 | |
48 | KCmdLineArgs::init( argc, argv, &aboutData ); |
49 | |
50 | KCmdLineOptions options; |
51 | options.add( "type <type>" , ki18n( "Only offer accounts that support the given type." ) ); |
52 | options.add( "assistant <assistant>" , ki18n( "Run the specified assistant." ) ); |
53 | options.add( "package <fullpath>" , ki18n( "unpack fullpath on startup and launch that assistant" ) ); |
54 | KCmdLineArgs::addCmdLineOptions( options ); |
55 | KUniqueApplication::addCmdLineOptions(); |
56 | |
57 | if ( !KUniqueApplication::start() ) { |
58 | fprintf( stderr, "accountwizard is already running!\n" ); |
59 | exit( 0 ); |
60 | } |
61 | |
62 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
63 | |
64 | KUniqueApplication app; |
65 | KGlobal::locale()->insertCatalog( QLatin1String("libakonadi" ) ); |
66 | |
67 | Akonadi::Control::start( 0 ); |
68 | |
69 | if ( !args->getOption( "package" ).isEmpty() ) { |
70 | Global::setAssistant( Global::unpackAssistant( KUrl( args->getOption( "package" ) ) ) ); |
71 | } else |
72 | Global::setAssistant( args->getOption( "assistant" ) ); |
73 | |
74 | if ( !args->getOption( "type" ).isEmpty() ) |
75 | Global::setTypeFilter( args->getOption( "type" ).split( QLatin1Char(',') ) ); |
76 | args->clear(); |
77 | Dialog dlg( 0/*, Qt::WindowStaysOnTopHint*/ ); |
78 | dlg.show(); |
79 | |
80 | return app.exec(); |
81 | } |
82 | |