From 80eb461360eb39657ac21ce8070c02f071884e9a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jun 2011 10:01:14 +0200 Subject: ibus IM support for the xcb backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test code to check input methods using the ibus backend used on e.g. ubuntu. The IM code is not very sophisticated, but enough to test that things are working. Reviewed-by: Jørgen Lind --- src/platformsupport/inputmethods/ibus/ibus.pri | 11 + .../org.freedesktop.IBus.InputContext.xml | 80 ++++++ .../ibus/interfaces/org.freedesktop.IBus.xml | 30 ++ .../inputmethods/ibus/qibusinputcontextproxy.cpp | 26 ++ .../inputmethods/ibus/qibusinputcontextproxy.h | 144 ++++++++++ .../ibus/qibusplatforminputcontext.cpp | 301 +++++++++++++++++++++ .../inputmethods/ibus/qibusplatforminputcontext.h | 71 +++++ .../inputmethods/ibus/qibusproxy.cpp | 26 ++ src/platformsupport/inputmethods/ibus/qibusproxy.h | 88 ++++++ .../inputmethods/ibus/qibustypes.cpp | 209 ++++++++++++++ src/platformsupport/inputmethods/ibus/qibustypes.h | 116 ++++++++ src/platformsupport/inputmethods/inputmethods.pri | 3 + 12 files changed, 1105 insertions(+) create mode 100644 src/platformsupport/inputmethods/ibus/ibus.pri create mode 100644 src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml create mode 100644 src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml create mode 100644 src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp create mode 100644 src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h create mode 100644 src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp create mode 100644 src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h create mode 100644 src/platformsupport/inputmethods/ibus/qibusproxy.cpp create mode 100644 src/platformsupport/inputmethods/ibus/qibusproxy.h create mode 100644 src/platformsupport/inputmethods/ibus/qibustypes.cpp create mode 100644 src/platformsupport/inputmethods/ibus/qibustypes.h create mode 100644 src/platformsupport/inputmethods/inputmethods.pri (limited to 'src/platformsupport/inputmethods') diff --git a/src/platformsupport/inputmethods/ibus/ibus.pri b/src/platformsupport/inputmethods/ibus/ibus.pri new file mode 100644 index 0000000000..c6e59aa484 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/ibus.pri @@ -0,0 +1,11 @@ +QT += dbus + +SOURCES += $$PWD/qibusplatforminputcontext.cpp \ + $$PWD/qibusproxy.cpp \ + $$PWD/qibusinputcontextproxy.cpp \ + $$PWD/qibustypes.cpp + +HEADERS += $$PWD/qibusplatforminputcontext.h \ + $$PWD/qibusproxy.h \ + $$PWD/qibusinputcontextproxy.h \ + $$PWD/qibustypes.h diff --git a/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml b/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml new file mode 100644 index 0000000000..dbc79c178b --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml b/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml new file mode 100644 index 0000000000..6ac4891771 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp b/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp new file mode 100644 index 0000000000..7adffbc2e2 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "qibusinputcontextproxy.h" + +/* + * Implementation of interface class QIBusInputContextProxy + */ + +QIBusInputContextProxy::QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +QIBusInputContextProxy::~QIBusInputContextProxy() +{ +} + diff --git a/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h b/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h new file mode 100644 index 0000000000..9a91c4e484 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h @@ -0,0 +1,144 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef QIBUSINPUTCONTEXTPROXY_H_1308831153 +#define QIBUSINPUTCONTEXTPROXY_H_1308831153 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface org.freedesktop.IBus.InputContext + */ +class QIBusInputContextProxy: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.freedesktop.IBus.InputContext"; } + +public: + QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~QIBusInputContextProxy(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> Destroy() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Destroy"), argumentList); + } + + inline QDBusPendingReply<> Disable() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Disable"), argumentList); + } + + inline QDBusPendingReply<> Enable() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Enable"), argumentList); + } + + inline QDBusPendingReply<> FocusIn() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("FocusIn"), argumentList); + } + + inline QDBusPendingReply<> FocusOut() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("FocusOut"), argumentList); + } + + inline QDBusPendingReply GetEngine() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("GetEngine"), argumentList); + } + + inline QDBusPendingReply IsEnabled() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("IsEnabled"), argumentList); + } + + inline QDBusPendingReply ProcessKeyEvent(uint keyval, uint keycode, uint state) + { + QList argumentList; + argumentList << QVariant::fromValue(keyval) << QVariant::fromValue(keycode) << QVariant::fromValue(state); + return asyncCallWithArgumentList(QLatin1String("ProcessKeyEvent"), argumentList); + } + + inline QDBusPendingReply<> PropertyActivate(const QString &name, int state) + { + QList argumentList; + argumentList << QVariant::fromValue(name) << QVariant::fromValue(state); + return asyncCallWithArgumentList(QLatin1String("PropertyActivate"), argumentList); + } + + inline QDBusPendingReply<> Reset() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Reset"), argumentList); + } + + inline QDBusPendingReply<> SetCapabilities(uint caps) + { + QList argumentList; + argumentList << QVariant::fromValue(caps); + return asyncCallWithArgumentList(QLatin1String("SetCapabilities"), argumentList); + } + + inline QDBusPendingReply<> SetCursorLocation(int x, int y, int w, int h) + { + QList argumentList; + argumentList << QVariant::fromValue(x) << QVariant::fromValue(y) << QVariant::fromValue(w) << QVariant::fromValue(h); + return asyncCallWithArgumentList(QLatin1String("SetCursorLocation"), argumentList); + } + + inline QDBusPendingReply<> SetEngine(const QString &name) + { + QList argumentList; + argumentList << QVariant::fromValue(name); + return asyncCallWithArgumentList(QLatin1String("SetEngine"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void CommitText(const QDBusVariant &text); + void CursorDownLookupTable(); + void CursorUpLookupTable(); + void Disabled(); + void Enabled(); + void ForwardKeyEvent(uint keyval, uint keycode, uint state); + void HideAuxiliaryText(); + void HideLookupTable(); + void HidePreeditText(); + void PageDownLookupTable(); + void PageUpLookupTable(); + void RegisterProperties(const QDBusVariant &props); + void ShowAuxiliaryText(); + void ShowLookupTable(); + void ShowPreeditText(); + void UpdateAuxiliaryText(const QDBusVariant &text, bool visible); + void UpdateLookupTable(const QDBusVariant &table, bool visible); + void UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); + void UpdateProperty(const QDBusVariant &prop); +}; + +#endif diff --git a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp new file mode 100644 index 0000000000..f0a3270665 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp @@ -0,0 +1,301 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qibusplatforminputcontext.h" + +#include +#include +#include +#include + +#include "qibusproxy.h" +#include "qibusinputcontextproxy.h" +#include "qibustypes.h" + +#include +#include + +#include + +class QIBusPlatformInputContextPrivate +{ +public: + QIBusPlatformInputContextPrivate(); + ~QIBusPlatformInputContextPrivate() + { + delete context; + delete bus; + delete connection; + } + + static QDBusConnection *createConnection(); + + QDBusConnection *connection; + QIBusProxy *bus; + QIBusInputContextProxy *context; + + bool valid; +}; + + +QIBusPlatformInputContext::QIBusPlatformInputContext () + : d(new QIBusPlatformInputContextPrivate()) +{ + connect(d->context, SIGNAL(CommitText(QDBusVariant)), SLOT(commitText(QDBusVariant))); + connect(d->context, SIGNAL(UpdatePreeditText(QDBusVariant,uint,bool)), this, SLOT(updatePreeditText(QDBusVariant,uint,bool))); +} + +QIBusPlatformInputContext::~QIBusPlatformInputContext (void) +{ + delete d; +} + +void QIBusPlatformInputContext::mouseHandler (int x, QMouseEvent *event) +{ + QPlatformInputContext::mouseHandler (x, event); + + if (!d->valid) + return; +} + +void QIBusPlatformInputContext::reset() +{ + QPlatformInputContext::reset(); + + if (!d->valid) + return; + + d->context->Reset(); +} + +void QIBusPlatformInputContext::update() +{ + QPlatformInputContext::update(); + + if (!d->valid) + return; + + QObject *o = focusObject(); + if (!o) + return; + + QInputMethodQueryEvent query(Qt::ImMicroFocus); + QGuiApplication::sendEvent(o, &query); + QRect r = query.value().toRect(); + if(r.isValid()) { + qDebug() << "mocroFocus" << r; + d->context->SetCursorLocation(r.x(), r.y(), r.width(), r.height()); + } +} + +void QIBusPlatformInputContext::setFocusObject(QObject *object) +{ + QPlatformInputContext::setFocusObject(object); + + if (!d->valid) + return; + + qDebug() << "setFocusObject" << object; + if (object) + d->context->FocusIn(); + else + d->context->FocusOut(); +} + + +void QIBusPlatformInputContext::commitText(const QDBusVariant &text) +{ + const QDBusArgument arg = text.variant().value(); + + QIBusText t; + qDebug() << arg.currentSignature(); + t.fromDBusArgument(arg); + qDebug() << "commit text:" << t.text; + + QInputMethodEvent event; + event.setCommitString(t.text); + QCoreApplication::sendEvent(focusObject(), &event); +} + +void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint cursorPos, bool visible) +{ + const QDBusArgument arg = text.variant().value(); + + QIBusText t; + t.fromDBusArgument(arg); + qDebug() << "preedit text:" << t.text; + + QList attributes = t.attributes.imAttributes(); + attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPos, visible ? 1 : 0, QVariant()); + + QInputMethodEvent event(t.text, attributes); + QCoreApplication::sendEvent(focusObject(), &event); +} + + +/* Kernel keycode -> X keycode table */ +static const unsigned int keycode_table[256] = { + 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 76, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 111, 221, 94, 95, 96, 211, 128, 127, 129, 208, 131, 126, + 108, 109, 112, 111, 113, 181, 97, 98, 99, 100, 102, 103, 104, 105, 106, 107, + 239, 160, 174, 176, 222, 157, 123, 110, 139, 134, 209, 210, 133, 115, 116, 117, + 232, 133, 134, 135, 140, 248, 191, 192, 122, 188, 245, 158, 161, 193, 223, 227, + 198, 199, 200, 147, 159, 151, 178, 201, 146, 203, 166, 236, 230, 235, 234, 233, + 163, 204, 253, 153, 162, 144, 164, 177, 152, 190, 208, 129, 130, 231, 209, 210, + 136, 220, 143, 246, 251, 137, 138, 182, 183, 184, 93, 184, 247, 132, 170, 219, + 249, 205, 207, 149, 150, 154, 155, 167, 168, 169, 171, 172, 173, 165, 175, 179, + 180, 0, 185, 186, 187, 118, 119, 120, 121, 229, 194, 195, 196, 197, 148, 202, + 101, 212, 237, 214, 215, 216, 217, 218, 228, 142, 213, 240, 241, 242, 243, 244, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +bool +QIBusPlatformInputContext::x11FilterEvent(uint keyval, uint keycode, uint state, bool press) +{ + if (!d->valid) + return false; + + if (!press) + return false; + + keycode -= 8; // ### + QDBusReply reply = d->context->ProcessKeyEvent(keyval, keycode, state); + +// qDebug() << "x11FilterEvent return" << reply.value(); + + return reply.value(); +} + +QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate() + : connection(createConnection()), + bus(0), + context(0), + valid(false) +{ + if (!connection->isConnected()) { + qDebug() << "not connected"; + return; + } + + bus = new QIBusProxy(QLatin1String("org.freedesktop.IBus"), + QLatin1String("/org/freedesktop/IBus"), + *connection); + if (!bus->isValid()) { + qDebug() << "invalid bus"; + return; + } + + QDBusReply ic = bus->CreateInputContext(QLatin1String("QIBusInputContext")); + if (!ic.isValid()) { + qDebug() << "CreateInputContext failed"; + return; + } + + context = new QIBusInputContextProxy(QLatin1String("org.freedesktop.IBus"), ic.value().path(), *connection); + + if (!context->isValid()) { + qDebug() << "invalid input context"; + return; + } + + enum Capabilities { + IBUS_CAP_PREEDIT_TEXT = 1 << 0, + IBUS_CAP_AUXILIARY_TEXT = 1 << 1, + IBUS_CAP_LOOKUP_TABLE = 1 << 2, + IBUS_CAP_FOCUS = 1 << 3, + IBUS_CAP_PROPERTY = 1 << 4, + IBUS_CAP_SURROUNDING_TEXT = 1 << 5, + }; + context->SetCapabilities(IBUS_CAP_PREEDIT_TEXT|IBUS_CAP_FOCUS); + + qDebug() << ">>>> valid!"; + valid = true; +} + +QDBusConnection *QIBusPlatformInputContextPrivate::createConnection() +{ + QByteArray display(getenv("DISPLAY")); + QByteArray host = "unix"; + QByteArray displayNumber = "0"; + + int pos = display.indexOf(':'); + if (pos > 0) + host = display.left(pos); + ++pos; + int pos2 = display.indexOf('.', pos); + if (pos2 > 0) + displayNumber = display.mid(pos, pos2 - pos); + qDebug() << "host=" << host << "displayNumber" << displayNumber; + + QFile file(QDir::homePath() + QLatin1String("/.config/ibus/bus/") + + QLatin1String(QDBusConnection::localMachineId()) + + QLatin1Char('-') + QString::fromLocal8Bit(host) + QLatin1Char('-') + QString::fromLocal8Bit(displayNumber)); + + if (!file.exists()) { + qDebug() << "ibus config file does not exist"; + return 0; + } + + file.open(QFile::ReadOnly); + + QByteArray address; + int pid = -1; + + while (!file.atEnd()) { + QByteArray line = file.readLine().trimmed(); + if (line.startsWith('#')) + continue; + + if (line.startsWith("IBUS_ADDRESS=")) + address = line.mid(sizeof("IBUS_ADDRESS=") - 1); + if (line.startsWith("IBUS_DAEMON_PID=")) + pid = line.mid(sizeof("IBUS_DAEMON_PID=") - 1).toInt(); + } + + qDebug() << "IBUS_ADDRESS=" << address << "PID=" << pid; + if (address.isEmpty() || pid < 0 || kill(pid, 0) != 0) + return 0; + + return new QDBusConnection(QDBusConnection::connectToBus(QString::fromLatin1(address), QLatin1String("QIBusProxy"))); +} diff --git a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h new file mode 100644 index 0000000000..6912fe4c20 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QIBUSPLATFORMINPUTCONTEXT_H +#define QIBUSPLATFORMINPUTCONTEXT_H + +#include + +class QIBusPlatformInputContextPrivate; +class QDBusVariant; + +class QIBusPlatformInputContext : public QObject, public QPlatformInputContext +{ + Q_OBJECT +public: + QIBusPlatformInputContext(); + ~QIBusPlatformInputContext(); + + void mouseHandler(int x, QMouseEvent *event); + void reset(void); + void update(void); + void setFocusObject(QObject *object); + + bool x11FilterEvent(uint keyval, uint keycode, uint state, bool press); + +public Q_SLOTS: + void commitText(const QDBusVariant &text); + void updatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); + +private: + QIBusPlatformInputContextPrivate *d; +}; + +#endif diff --git a/src/platformsupport/inputmethods/ibus/qibusproxy.cpp b/src/platformsupport/inputmethods/ibus/qibusproxy.cpp new file mode 100644 index 0000000000..9d64b603f3 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibusproxy.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusproxy -c QIBusProxy interfaces/org.freedesktop.IBus.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "qibusproxy.h" + +/* + * Implementation of interface class QIBusProxy + */ + +QIBusProxy::QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +QIBusProxy::~QIBusProxy() +{ +} + diff --git a/src/platformsupport/inputmethods/ibus/qibusproxy.h b/src/platformsupport/inputmethods/ibus/qibusproxy.h new file mode 100644 index 0000000000..389eec3175 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibusproxy.h @@ -0,0 +1,88 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusproxy -c QIBusProxy interfaces/org.freedesktop.IBus.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef QIBUSPROXY_H_1308831142 +#define QIBUSPROXY_H_1308831142 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface org.freedesktop.IBus + */ +class QIBusProxy: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.freedesktop.IBus"; } + +public: + QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~QIBusProxy(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply CreateInputContext(const QString &name) + { + QList argumentList; + argumentList << QVariant::fromValue(name); + return asyncCallWithArgumentList(QLatin1String("CreateInputContext"), argumentList); + } + + inline QDBusPendingReply<> Exit(bool restart) + { + QList argumentList; + argumentList << QVariant::fromValue(restart); + return asyncCallWithArgumentList(QLatin1String("Exit"), argumentList); + } + + inline QDBusPendingReply GetAddress() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("GetAddress"), argumentList); + } + + inline QDBusPendingReply ListActiveEngines() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("ListActiveEngines"), argumentList); + } + + inline QDBusPendingReply ListEngines() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("ListEngines"), argumentList); + } + + inline QDBusPendingReply Ping(const QDBusVariant &data) + { + QList argumentList; + argumentList << QVariant::fromValue(data); + return asyncCallWithArgumentList(QLatin1String("Ping"), argumentList); + } + + inline QDBusPendingReply<> RegisterComponent(const QDBusVariant &components) + { + QList argumentList; + argumentList << QVariant::fromValue(components); + return asyncCallWithArgumentList(QLatin1String("RegisterComponent"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +#endif diff --git a/src/platformsupport/inputmethods/ibus/qibustypes.cpp b/src/platformsupport/inputmethods/ibus/qibustypes.cpp new file mode 100644 index 0000000000..8d8c61afb7 --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibustypes.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qibustypes.h" +#include +#include + +QIBusSerializable::QIBusSerializable() +{ +} + +QIBusSerializable::~QIBusSerializable() +{ +} + +void QIBusSerializable::fromDBusArgument(const QDBusArgument &arg) +{ + arg >> name; + arg.beginMap(); + while (!arg.atEnd()) { + arg.beginMapEntry(); + QString key; + QDBusVariant value; + arg >> key; + arg >> value; + arg.endMapEntry(); + attachments[key] = value.variant().value(); + } + arg.endMap(); +} + + + +QIBusAttribute::QIBusAttribute() + : type(Invalid), + value(0), + start(0), + end(0) +{ +} + +QIBusAttribute::~QIBusAttribute() +{ + +} + +void QIBusAttribute::fromDBusArgument(const QDBusArgument &arg) +{ +// qDebug() << "QIBusAttribute::fromDBusArgument()" << arg.currentSignature(); + arg.beginStructure(); + + QIBusSerializable::fromDBusArgument(arg); + + quint32 t; + arg >> t; + type = (Type)t; + arg >> value; + arg >> start; + arg >> end; + + arg.endStructure(); +} + +QTextFormat QIBusAttribute::format() const +{ + QTextCharFormat fmt; + switch (type) { + case Invalid: + break; + case Underline: { + QTextCharFormat::UnderlineStyle style = QTextCharFormat::NoUnderline; + + switch (value) { + case UnderlineNone: + break; + case UnderlineSingle: + style = QTextCharFormat::SingleUnderline; + break; + case UnderlineDouble: + style = QTextCharFormat::DashUnderline; + break; + case UnderlineLow: + style = QTextCharFormat::DashDotLine; + break; + case UnderlineError: + style = QTextCharFormat::WaveUnderline; + fmt.setUnderlineColor(Qt::red); + break; + } + + fmt.setUnderlineStyle(style); + break; + } + case Foreground: + fmt.setForeground(QColor(value)); + break; + case Background: + fmt.setBackground(QColor(value)); + break; + } + return fmt; +} + + +QIBusAttributeList::QIBusAttributeList() +{ + +} + +QIBusAttributeList::~QIBusAttributeList() +{ + +} + +void QIBusAttributeList::fromDBusArgument(const QDBusArgument &arg) +{ +// qDebug() << "QIBusAttributeList::fromDBusArgument()" << arg.currentSignature(); + arg.beginStructure(); + + QIBusSerializable::fromDBusArgument(arg); + + arg.beginArray(); + while(!arg.atEnd()) { + QDBusVariant var; + arg >> var; + + QIBusAttribute attr; + attr.fromDBusArgument(var.variant().value()); + attributes.append(attr); + } + arg.endArray(); + + arg.endStructure(); +} + +QList QIBusAttributeList::imAttributes() const +{ + QList imAttrs; + for (int i = 0; i < attributes.size(); ++i) { + const QIBusAttribute &attr = attributes.at(i); + imAttrs += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, attr.start, attr.end - attr.start, attr.format()); + } + return imAttrs; +} + + +QIBusText::QIBusText() +{ + +} + +QIBusText::~QIBusText() +{ + +} + +void QIBusText::fromDBusArgument(const QDBusArgument &arg) +{ +// qDebug() << "QIBusText::fromDBusArgument()" << arg.currentSignature(); + arg.beginStructure(); + + QIBusSerializable::fromDBusArgument(arg); + + arg >> text; + QDBusVariant variant; + arg >> variant; + attributes.fromDBusArgument(variant.variant().value()); + + arg.endStructure(); +} + diff --git a/src/platformsupport/inputmethods/ibus/qibustypes.h b/src/platformsupport/inputmethods/ibus/qibustypes.h new file mode 100644 index 0000000000..c426ff7eda --- /dev/null +++ b/src/platformsupport/inputmethods/ibus/qibustypes.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QIBUSTYPES_H +#define QIBUSTYPES_H + +#include +#include + +class QDBusArgument; + +class QIBusSerializable +{ +public: + QIBusSerializable(); + virtual ~QIBusSerializable(); + + virtual void fromDBusArgument(const QDBusArgument &arg); + + QString name; + QHash attachments; +}; + +class QIBusAttribute : public QIBusSerializable +{ +public: + enum Type { + Invalid = 0, + Underline = 1, + Foreground = 2, + Background = 3, + }; + + enum Underline { + UnderlineNone = 0, + UnderlineSingle = 1, + UnderlineDouble = 2, + UnderlineLow = 3, + UnderlineError = 4, + }; + + QIBusAttribute(); + ~QIBusAttribute(); + + void fromDBusArgument(const QDBusArgument &arg); + QTextFormat format() const; + + Type type; + quint32 value; + quint32 start; + quint32 end; +}; + +class QIBusAttributeList : public QIBusSerializable +{ +public: + QIBusAttributeList(); + ~QIBusAttributeList(); + + void fromDBusArgument(const QDBusArgument &arg); + + QList imAttributes() const; + + QVector attributes; +}; + +class QIBusText : public QIBusSerializable +{ +public: + QIBusText(); + ~QIBusText(); + + void fromDBusArgument(const QDBusArgument &arg); + + QString text; + QIBusAttributeList attributes; +}; + +#endif diff --git a/src/platformsupport/inputmethods/inputmethods.pri b/src/platformsupport/inputmethods/inputmethods.pri new file mode 100644 index 0000000000..93042b7252 --- /dev/null +++ b/src/platformsupport/inputmethods/inputmethods.pri @@ -0,0 +1,3 @@ +unix { + include($$PWD/ibus/ibus.pri) +} -- cgit v1.2.3