15
15
#include "connectionfactory.h"
17
#ifndef MALIIT_DISABLE_DBUS
19
#include "glibdbusimserverproxy.h"
20
#include "minputcontextglibdbusconnection.h"
22
#include "dbusserverconnection.h"
23
17
#include "dbusinputcontextconnection.h"
26
#include "mimdirectserverconnection.h"
28
19
#ifdef HAVE_WAYLAND
29
#include "minputcontextwestonimprotocolconnection.h"
20
#include "waylandinputmethodconnection.h"
33
#ifndef MALIIT_DISABLE_DBUS
36
MImServerConnection *createServerConnectionWithDynamicAddress()
38
const QSharedPointer<Maliit::InputContext::DBus::Address> address(new Maliit::InputContext::DBus::DynamicAddress);
40
return new GlibDBusIMServerProxy(address);
42
return new DBusServerConnection(address);
46
MImServerConnection *createServerConnectionWithFixedAddress(const QString &fixedAddress)
48
const QSharedPointer<Maliit::InputContext::DBus::Address> address(new Maliit::InputContext::DBus::FixedAddress(fixedAddress));
50
return new GlibDBusIMServerProxy(address);
52
return new DBusServerConnection(address);
56
26
MInputContextConnection *createInputContextConnectionWithDynamicAddress()
59
std::tr1::shared_ptr<Maliit::Server::DBus::Address> address(new Maliit::Server::DBus::DynamicAddress);
60
return new MInputContextGlibDBusConnection(address, false);
62
28
QSharedPointer<Maliit::Server::DBus::Address> address(new Maliit::Server::DBus::DynamicAddress);
63
29
return new DBusInputContextConnection(address);
67
32
MInputContextConnection *createInputContextConnectionWithFixedAddress(const QString &fixedAddress, bool allowAnonymous)
70
std::tr1::shared_ptr<Maliit::Server::DBus::Address> address(new Maliit::Server::DBus::FixedAddress(fixedAddress));
71
return new MInputContextGlibDBusConnection(address, allowAnonymous);
73
34
Q_UNUSED(allowAnonymous);
74
35
QSharedPointer<Maliit::Server::DBus::Address> address(new Maliit::Server::DBus::FixedAddress(fixedAddress));
75
36
return new DBusInputContextConnection(address);
79
39
} // namespace DBus
80
#endif // MALIIT_DISABLE_DBUS
82
41
#ifdef HAVE_WAYLAND
83
42
MInputContextConnection *createWestonIMProtocolConnection()
85
return new MInputContextWestonIMProtocolConnection;
89
QSharedPointer<MImServerConnection> createServerConnection(const QString &connectionType)
91
typedef QSharedPointer<MImServerConnection> ConnectionPtr;
92
static QWeakPointer<MImServerConnection> cached_connection;
94
if (ConnectionPtr connection = cached_connection.toStrongRef()) {
98
if (connectionType.isEmpty()) {
99
qCritical() << "Empty connection type name. Refusing to connect to Maliit server."
100
<< "\nHave you checked the environment variables for loading input method"
101
<< "modules ([QT|GTK]_IM_MODULE)?";
102
return ConnectionPtr();
105
if (connectionType == MALIIT_INPUTCONTEXT_NAME) {
106
#ifndef MALIIT_DISABLE_DBUS
107
const QByteArray overriddenAddress = qgetenv("MALIIT_SERVER_ADDRESS");
108
ConnectionPtr connection = ConnectionPtr(overriddenAddress.isEmpty()
109
? Maliit::DBus::createServerConnectionWithDynamicAddress()
110
: Maliit::DBus::createServerConnectionWithFixedAddress(overriddenAddress));
111
cached_connection = connection;
115
qCritical("This connection type to Maliit server is not available since DBus support is disabled");
117
} else if (connectionType == MALIIT_INPUTCONTEXT_NAME"Direct") {
118
ConnectionPtr connection(new MImDirectServerConnection);
120
cached_connection = connection;
124
qCritical() << __PRETTY_FUNCTION__
125
<< "Invalid connection type (" + connectionType + "),"
126
<< "unable to create connection to Maliit server";
127
return ConnectionPtr();
44
return new WaylandInputMethodConnection;
131
48
} // namespace Maliit