0d450f66b08d6191513741264f4b7f9a4111f037
[toast/confclerk.git] / src / app / main.cpp
1 /*
2  * Copyright (C) 2010 Ixonos Plc.
3  * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
4  *
5  * This file is part of ConfClerk.
6  *
7  * ConfClerk is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation, either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * ConfClerk is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <mainwindow.h>
21
22 #include <sqlengine.h>
23
24 #include "eventdialog.h"
25 #include "application.h"
26
27 #ifdef MAEMO
28 //#include <alarmdialog.h>
29 #include <alarmdbus.h>
30 #include <alarmdbusadaptorp.h>
31 #endif /* MAEMO */
32
33
34 int main(int argc, char *argv[])
35 {
36     Q_INIT_RESOURCE(icons);
37     Q_INIT_RESOURCE(db);
38     Q_INIT_RESOURCE(data);
39
40     Application a(argc, argv);
41     Application::setWindowIcon(QIcon(":/confclerk.svg"));
42
43     // needed by QDesktopServices
44     QCoreApplication::setOrganizationName("Toastfreeware");
45     QCoreApplication::setApplicationName("ConfClerk");
46  
47     SqlEngine::initialize(); // creates "SQLITE" DB connection
48
49     QWidget *window;
50
51     window = new MainWindow;
52
53
54 #ifdef MAEMO
55     // Alarm Dbus
56     CAlarmDBus *alarmDBus = new CAlarmDBus(window);
57     new AlarmDBusAdaptor(alarmDBus);
58     QDBusConnection connection = QDBusConnection::sessionBus();
59
60     if(connection.registerObject("/ConfClerk", alarmDBus) == true)
61     {
62         if( connection.registerService("at.priv.toastfreeware.confclerk") == false)
63         {
64                 if(argc>1)
65                 {
66                         QDBusInterface *interface = new QDBusInterface("at.priv.toastfreeware.confclerk",
67                                                                        "/ConfClerk",
68                                                                        "at.priv.toastfreeware.confclerk.AlarmInterface",
69                                                                        connection);
70                         interface->call("Alarm",atoi(argv[1]));
71                         return 0;
72                 }
73         }
74     }
75
76     if(argc > 1)
77     {
78         EventDialog dialog(atoi(argv[1]),window);
79         dialog.exec();
80     }
81 #endif
82
83     window->show();
84
85     return a.exec();
86 }
87