1 | /* |
2 | * Copyright (c) 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2.1 of the License, or (at your option) any later version. |
8 | * |
9 | * This library 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 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #include "resource.h" |
19 | #include "script.h" |
20 | #include "xmloperations.h" |
21 | #include "global.h" |
22 | #include "test.h" |
23 | #include "collectiontest.h" |
24 | #include "itemtest.h" |
25 | #include "system.h" |
26 | #include "qemu.h" |
27 | |
28 | #include <akonadi/control.h> |
29 | |
30 | #include <KApplication> |
31 | #include <KAboutData> |
32 | #include <KCmdLineArgs> |
33 | #include <KDebug> |
34 | |
35 | #include <QCoreApplication> |
36 | #include <QtCore/QTimer> |
37 | #include <QFileInfo> |
38 | |
39 | #include <signal.h> |
40 | |
41 | void sigHandler( int signal) |
42 | { |
43 | Q_UNUSED( signal ); |
44 | QCoreApplication::quit(); |
45 | } |
46 | |
47 | int main(int argc, char *argv[]) |
48 | { |
49 | QString path; |
50 | |
51 | KAboutData aboutdata( "akonadi-RT" , 0, |
52 | ki18n( "Akonadi Resource Tester" ), |
53 | "1.0" , |
54 | ki18n( "Resource Tester" ), |
55 | KAboutData::License_GPL, |
56 | ki18n( "(c) 2009 Igor Trindade Oliveira" ) ); |
57 | |
58 | KCmdLineArgs::init( argc, argv, &aboutdata ); |
59 | |
60 | |
61 | KCmdLineOptions options; |
62 | options.add( "c" ).add( "config <configfile>" , ki18n( "Configuration file to open" ), "script.js/py/rb" ); |
63 | KCmdLineArgs::addCmdLineOptions( options ); |
64 | |
65 | KApplication app; |
66 | |
67 | const KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
68 | |
69 | if ( args->isSet( "config" ) ) |
70 | path.append(args->getOption( "config" )) ; |
71 | else |
72 | return -1; |
73 | Global::setBasePath( QFileInfo( path ).absolutePath() ); |
74 | |
75 | #ifdef Q_OS_UNIX |
76 | signal( SIGINT, sigHandler ); |
77 | signal( SIGQUIT, sigHandler ); |
78 | #endif |
79 | |
80 | if ( !Akonadi::Control::start() ) |
81 | qFatal( "Unable to start Akonadi!" ); |
82 | |
83 | Script *script = new Script(); |
84 | |
85 | script->configure(path); |
86 | script->insertObject( new XmlOperations( Global::parent() ), "XmlOperations" ); |
87 | script->insertObject( new Resource( Global::parent() ), "Resource" ); |
88 | script->insertObject( Test::instance(), "Test" ); |
89 | script->insertObject( new CollectionTest( Global::parent() ), "CollectionTest" ); |
90 | script->insertObject( new ItemTest( Global::parent() ), "ItemTest" ); |
91 | script->insertObject( new System( Global::parent() ), "System" ); |
92 | script->insertObject( new QEmu( Global::parent() ), "QEmu" ); |
93 | QTimer::singleShot( 0, script, SLOT(start()) ); |
94 | |
95 | const int result = app.exec(); |
96 | Global::cleanup(); |
97 | return result; |
98 | } |
99 | |