1
/* * This file is part of Maliit framework *
3
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: maliit-discuss@lists.maliit.org
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License version 2.1 as published by the Free Software Foundation
11
* and appearing in the file LICENSE.LGPL included in the packaging
17
#include "connectionfactory.h"
18
#include "mimserver.h"
19
#include "mimserveroptions.h"
21
#include "xcbplatform.h"
24
#include "waylandplatform.h"
25
#endif // HAVE_WAYLAND
26
#include "unknownplatform.h"
28
#include <QGuiApplication>
33
void disableMInputContextPlugin()
35
// none is a special value for QT_IM_MODULE, which disables loading of any
36
// input method module in Qt 5.
37
setenv("QT_IM_MODULE", "none", true);
42
static int debugEnabled = -1;
44
if (debugEnabled == -1) {
45
QByteArray debugEnvVar = qgetenv("MALIIT_DEBUG");
46
if (!debugEnvVar.isEmpty() && debugEnvVar != "0") {
53
return debugEnabled == 1;
56
void outputMessagesToStdErr(QtMsgType type,
57
const QMessageLogContext &context,
61
QByteArray utf_text(msg.toUtf8());
62
const char *raw(utf_text.constData());
66
if (isDebugEnabled()) {
67
fprintf(stderr, "DEBUG: %s\n", raw);
71
fprintf(stderr, "WARNING: %s\n", raw);
74
fprintf(stderr, "CRITICAL: %s\n", raw);
77
fprintf(stderr, "FATAL: %s\n", raw);
82
QSharedPointer<MInputContextConnection> createConnection(const MImServerConnectionOptions &options)
85
if (QGuiApplication::platformName().startsWith("wayland")) {
86
return QSharedPointer<MInputContextConnection>(Maliit::createWestonIMProtocolConnection());
89
if (options.overriddenAddress.isEmpty()) {
90
return QSharedPointer<MInputContextConnection>(Maliit::DBus::createInputContextConnectionWithDynamicAddress());
92
return QSharedPointer<MInputContextConnection>(Maliit::DBus::createInputContextConnectionWithFixedAddress(options.overriddenAddress,
93
options.allowAnonymous));
97
QSharedPointer<Maliit::AbstractPlatform> createPlatform()
100
if (QGuiApplication::platformName().startsWith("wayland")) {
101
return QSharedPointer<Maliit::AbstractPlatform>(new Maliit::WaylandPlatform);
105
if (QGuiApplication::platformName() == "xcb") {
106
return QSharedPointer<Maliit::AbstractPlatform>(new Maliit::XCBPlatform);
111
return QSharedPointer<Maliit::AbstractPlatform>(new Maliit::UnknownPlatform);
115
} // unnamed namespace
117
int main(int argc, char **argv)
119
qInstallMessageHandler(outputMessagesToStdErr);
121
// QT_IM_MODULE, MApplication and QtMaemo5Style all try to load
122
// MInputContext, which is fine for the application. For the passthrough
123
// server itself, we absolutely need to prevent that.
124
disableMInputContextPlugin();
126
MImServerCommonOptions serverCommonOptions;
127
MImServerConnectionOptions connectionOptions;
129
const bool allRecognized = parseCommandLine(argc, argv);
130
if (serverCommonOptions.showHelp) {
133
} else if (not allRecognized) {
137
QGuiApplication app(argc, argv);
139
// Input Context Connection
140
QSharedPointer<MInputContextConnection> icConnection(createConnection(connectionOptions));
142
QSharedPointer<Maliit::AbstractPlatform> platform(createPlatform());
145
MImServer::configureSettings(MImServer::PersistentSettings);
146
MImServer imServer(icConnection, platform);