Changeset View
Changeset View
Standalone View
Standalone View
krfb/main.cpp
Show All 33 Lines | |||||
34 | #include <signal.h> | 34 | #include <signal.h> | ||
35 | #include <X11/extensions/XTest.h> | 35 | #include <X11/extensions/XTest.h> | ||
36 | #include <QCommandLineParser> | 36 | #include <QCommandLineParser> | ||
37 | #include <QCommandLineOption> | 37 | #include <QCommandLineOption> | ||
38 | 38 | | |||
39 | 39 | | |||
40 | static const char description[] = I18N_NOOP("VNC-compatible server to share " | 40 | static const char description[] = I18N_NOOP("VNC-compatible server to share " | ||
41 | "desktops"); | 41 | "desktops"); | ||
42 | | ||||
43 | static bool checkX11Capabilities() | 42 | static bool checkX11Capabilities() | ||
44 | { | 43 | { | ||
45 | int bp1, bp2, majorv, minorv; | 44 | int bp1, bp2, majorv, minorv; | ||
46 | Bool r = XTestQueryExtension(QX11Info::display(), &bp1, &bp2, | 45 | Bool r = XTestQueryExtension(QX11Info::display(), &bp1, &bp2, | ||
47 | &majorv, &minorv); | 46 | &majorv, &minorv); | ||
48 | 47 | | |||
49 | if ((!r) || (((majorv * 1000) + minorv) < 2002)) { | 48 | if ((!r) || (((majorv * 1000) + minorv) < 2002)) { | ||
50 | KMessageBox::error(nullptr, | 49 | KMessageBox::error(nullptr, | ||
51 | i18n("Your X11 Server does not support the required XTest extension " | 50 | i18n("Your X11 Server does not support the required XTest extension " | ||
52 | "version 2.2. Sharing your desktop is not possible."), | 51 | "version 2.2. Sharing your desktop is not possible."), | ||
53 | i18n("Desktop Sharing Error")); | 52 | i18n("Desktop Sharing Error")); | ||
54 | return false; | 53 | return false; | ||
55 | } | 54 | } | ||
56 | 55 | | |||
57 | return true; | 56 | return true; | ||
58 | } | 57 | } | ||
59 | 58 | | |||
60 | | ||||
61 | static void checkOldX11PluginConfig() { | 59 | static void checkOldX11PluginConfig() { | ||
62 | if (KrfbConfig::preferredFrameBufferPlugin() == QStringLiteral("x11")) { | 60 | if (KrfbConfig::preferredFrameBufferPlugin() == QStringLiteral("x11")) { | ||
63 | qDebug() << "Detected deprecated configuration: preferredFrameBufferPlugin = x11"; | 61 | qDebug() << "Detected deprecated configuration: preferredFrameBufferPlugin = x11"; | ||
64 | KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem( | 62 | KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem( | ||
65 | QStringLiteral("preferredFrameBufferPlugin")); | 63 | QStringLiteral("preferredFrameBufferPlugin")); | ||
66 | if (config_item) { | 64 | if (config_item) { | ||
67 | config_item->setProperty(QStringLiteral("xcb")); | 65 | config_item->setProperty(QStringLiteral("xcb")); | ||
68 | KrfbConfig::self()->save(); | 66 | KrfbConfig::self()->save(); | ||
69 | qDebug() << " Fixed preferredFrameBufferPlugin from x11 to xcb."; | 67 | qDebug() << " Fixed preferredFrameBufferPlugin from x11 to xcb."; | ||
70 | } | 68 | } | ||
71 | } | 69 | } | ||
72 | } | 70 | } | ||
73 | 71 | | |||
74 | | ||||
75 | int main(int argc, char *argv[]) | 72 | int main(int argc, char *argv[]) | ||
76 | { | 73 | { | ||
77 | QApplication app(argc, argv); | 74 | QApplication app(argc, argv); | ||
78 | 75 | | |||
79 | KLocalizedString::setApplicationDomain("krfb"); | 76 | KLocalizedString::setApplicationDomain("krfb"); | ||
80 | 77 | | |||
81 | KAboutData aboutData(QStringLiteral("krfb"), | 78 | KAboutData aboutData(QStringLiteral("krfb"), | ||
82 | i18n("Desktop Sharing"), | 79 | i18n("Desktop Sharing"), | ||
Show All 33 Lines | |||||
116 | 113 | | |||
117 | parser.process(app); | 114 | parser.process(app); | ||
118 | aboutData.processCommandLine(&parser); | 115 | aboutData.processCommandLine(&parser); | ||
119 | 116 | | |||
120 | KDBusService service(KDBusService::Unique, &app); | 117 | KDBusService service(KDBusService::Unique, &app); | ||
121 | 118 | | |||
122 | app.setQuitOnLastWindowClosed(false); | 119 | app.setQuitOnLastWindowClosed(false); | ||
123 | 120 | | |||
121 | if (QX11Info::isPlatformX11()) { | ||||
124 | if (!checkX11Capabilities()) { | 122 | if (!checkX11Capabilities()) { | ||
125 | return 1; | 123 | return 1; | ||
126 | } | 124 | } | ||
127 | 125 | | |||
128 | // upgrade the configuration | 126 | // upgrade the configuration | ||
129 | checkOldX11PluginConfig(); | 127 | checkOldX11PluginConfig(); | ||
128 | } | ||||
130 | 129 | | |||
131 | //init the core | 130 | //init the core | ||
132 | InvitationsRfbServer::init(); | 131 | InvitationsRfbServer::init(); | ||
133 | 132 | | |||
134 | //init the GUI | 133 | //init the GUI | ||
135 | MainWindow mainWindow; | 134 | MainWindow mainWindow; | ||
136 | TrayIcon trayicon(&mainWindow); | 135 | TrayIcon trayicon(&mainWindow); | ||
137 | 136 | | |||
Show All 15 Lines |