Changeset View
Changeset View
Standalone View
Standalone View
src/backends/julia/juliaserver/main.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * This program is free software; you can redistribute it and/or | ||||
3 | * modify it under the terms of the GNU General Public License | ||||
4 | * as published by the Free Software Foundation; either version 2 | ||||
5 | * of the License, or (at your option) any later version. | ||||
6 | * | ||||
7 | * This program is distributed in the hope that it will be useful, | ||||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
10 | * GNU General Public License for more details. | ||||
11 | * | ||||
12 | * You should have received a copy of the GNU General Public License | ||||
13 | * along with this program; if not, write to the Free Software | ||||
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
15 | * Boston, MA 02110-1301, USA. | ||||
16 | * | ||||
17 | * --- | ||||
18 | * Copyright (C) 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com> | ||||
19 | */ | ||||
20 | | ||||
21 | #include <QApplication> | ||||
22 | #include <QDBusConnection> | ||||
23 | #include <QDBusError> | ||||
24 | #include <QDebug> | ||||
25 | #include <QTextStream> | ||||
26 | | ||||
27 | #include "juliaserver.h" | ||||
28 | | ||||
29 | int main(int argc, char *argv[]) | ||||
30 | { | ||||
31 | QCoreApplication app(argc, argv); | ||||
32 | | ||||
33 | if (not QDBusConnection::sessionBus().isConnected()) { | ||||
34 | qWarning() << "Can't connect to the D-Bus session bus.\n" | ||||
35 | "To start it, run: eval `dbus-launch --auto-syntax`"; | ||||
36 | return 1; | ||||
37 | } | ||||
38 | | ||||
39 | const QString &serviceName = | ||||
40 | QString::fromLatin1("org.kde.Cantor.Julia-%1").arg(app.applicationPid()); | ||||
41 | | ||||
42 | if (not QDBusConnection::sessionBus().registerService(serviceName)) { | ||||
43 | qWarning() << QDBusConnection::sessionBus().lastError().message(); | ||||
44 | return 2; | ||||
45 | } | ||||
46 | | ||||
47 | JuliaServer server; | ||||
48 | QDBusConnection::sessionBus().registerObject( | ||||
49 | QLatin1String("/"), | ||||
50 | &server, | ||||
51 | QDBusConnection::ExportAllSlots | ||||
52 | ); | ||||
53 | | ||||
54 | QTextStream(stdout) << "ready" << endl; | ||||
55 | | ||||
56 | return app.exec(); | ||||
57 | } |