From a818a1eb2f3d2c5ac61da7e1a8cf1b341e63aed1 Mon Sep 17 00:00:00 2001 From: Kevin Krammer Date: Tue, 27 Mar 2012 18:39:49 +0200 Subject: Add implementation of virtual keyboard based on BPS events Change-Id: Ida4fa344c54db32b7b22b08a124b8c7b6df8adef Reviewed-by: Sean Harmer Reviewed-by: Nicolas Arnaud-Cormos Reviewed-by: Giuseppe D'Angelo --- src/plugins/platforms/qnx/qnx.pro | 10 +- src/plugins/platforms/qnx/qqnxbpseventfilter.cpp | 8 +- src/plugins/platforms/qnx/qqnxbpseventfilter.h | 5 +- src/plugins/platforms/qnx/qqnxintegration.cpp | 31 +- src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp | 430 --------------------- src/plugins/platforms/qnx/qqnxvirtualkeyboard.h | 101 ----- .../platforms/qnx/qqnxvirtualkeyboardbps.cpp | 209 ++++++++++ src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h | 72 ++++ .../platforms/qnx/qqnxvirtualkeyboardpps.cpp | 430 +++++++++++++++++++++ src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.h | 100 +++++ 10 files changed, 848 insertions(+), 548 deletions(-) delete mode 100644 src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp delete mode 100644 src/plugins/platforms/qnx/qqnxvirtualkeyboard.h create mode 100644 src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp create mode 100644 src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h create mode 100644 src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp create mode 100644 src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.h (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index c218b5e86e..7ca9ddf63a 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -84,11 +84,13 @@ contains(QT_CONFIG, opengles2) { CONFIG(blackberry) { SOURCES += qqnxnavigatorbps.cpp \ qqnxeventdispatcher_blackberry.cpp \ - qqnxbpseventfilter.cpp + qqnxbpseventfilter.cpp \ + qqnxvirtualkeyboardbps.cpp HEADERS += qqnxnavigatorbps.h \ qqnxeventdispatcher_blackberry.h \ - qqnxbpseventfilter.h + qqnxbpseventfilter.h \ + qqnxvirtualkeyboardbps.h LIBS += -lbps } @@ -98,12 +100,12 @@ CONFIG(qqnx_pps) { SOURCES += qqnxnavigatorpps.cpp \ qqnxnavigatoreventnotifier.cpp \ - qqnxvirtualkeyboard.cpp \ + qqnxvirtualkeyboardpps.cpp \ qqnxclipboard.cpp HEADERS += qqnxnavigatorpps.h \ qqnxnavigatoreventnotifier.h \ - qqnxvirtualkeyboard.h \ + qqnxvirtualkeyboardpps.h \ qqnxclipboard.h LIBS += -lpps -lclipboard diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp index 15391ff765..647e1a692f 100644 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp +++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp @@ -43,6 +43,7 @@ #include "qqnxnavigatoreventhandler.h" #include "qqnxscreen.h" #include "qqnxscreeneventhandler.h" +#include "qqnxvirtualkeyboardbps.h" #include #include @@ -56,10 +57,12 @@ QT_BEGIN_NAMESPACE static QQnxBpsEventFilter *s_instance = 0; QQnxBpsEventFilter::QQnxBpsEventFilter(QQnxNavigatorEventHandler *navigatorEventHandler, - QQnxScreenEventHandler *screenEventHandler, QObject *parent) + QQnxScreenEventHandler *screenEventHandler, + QQnxVirtualKeyboardBps *virtualKeyboard, QObject *parent) : QObject(parent) , m_navigatorEventHandler(navigatorEventHandler) , m_screenEventHandler(screenEventHandler) + , m_virtualKeyboard(virtualKeyboard) { Q_ASSERT(s_instance == 0); @@ -132,6 +135,9 @@ bool QQnxBpsEventFilter::bpsEventFilter(bps_event_t *event) if (eventDomain == navigator_get_domain()) return handleNavigatorEvent(event); + if (m_virtualKeyboard->handleEvent(event)) + return true; + return false; } diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.h b/src/plugins/platforms/qnx/qqnxbpseventfilter.h index 5965f2ca63..215027e8e6 100644 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.h +++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.h @@ -52,13 +52,15 @@ class QAbstractEventDispatcher; class QQnxNavigatorEventHandler; class QQnxScreen; class QQnxScreenEventHandler; +class QQnxVirtualKeyboardBps; class QQnxBpsEventFilter : public QObject { Q_OBJECT public: QQnxBpsEventFilter(QQnxNavigatorEventHandler *navigatorEventHandler, - QQnxScreenEventHandler *screenEventHandler, QObject *parent = 0); + QQnxScreenEventHandler *screenEventHandler, + QQnxVirtualKeyboardBps *virtualKeyboard, QObject *parent = 0); ~QQnxBpsEventFilter(); void installOnEventDispatcher(QAbstractEventDispatcher *dispatcher); @@ -75,6 +77,7 @@ private: private: QQnxNavigatorEventHandler *m_navigatorEventHandler; QQnxScreenEventHandler *m_screenEventHandler; + QQnxVirtualKeyboardBps *m_virtualKeyboard; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index b3208624e2..2fa3b45047 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -54,13 +54,14 @@ #if defined(Q_OS_BLACKBERRY) #include "qqnxbpseventfilter.h" #include "qqnxnavigatorbps.h" +#include "qqnxvirtualkeyboardbps.h" #elif defined(QQNX_PPS) #include "qqnxnavigatorpps.h" +#include "qqnxvirtualkeyboardpps.h" #endif #if defined(QQNX_PPS) # include "qqnxnavigatoreventnotifier.h" -# include "qqnxvirtualkeyboard.h" # include "qqnxclipboard.h" # if defined(QQNX_IMF) @@ -159,20 +160,14 @@ QQnxIntegration::QQnxIntegration() m_screenEventThread->start(); #endif -#if defined(QQNX_PPS) + // Not on BlackBerry, it has specialised event dispatcher which also handles virtual keyboard events +#if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) // Create/start the keyboard class. - m_virtualKeyboard = new QQnxVirtualKeyboard(); + m_virtualKeyboard = new QQnxVirtualKeyboardPps(); // delay invocation of start() to the time the event loop is up and running // needed to have the QThread internals of the main thread properly initialized QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection); - - // TODO check if we need to do this for all screens or only the primary one - QObject::connect(m_virtualKeyboard, SIGNAL(heightChanged(int)), - primaryDisplay(), SLOT(keyboardHeightChanged(int))); - - // Set up the input context - m_inputContext = new QQnxInputContext(*m_virtualKeyboard); #endif #if defined(Q_OS_BLACKBERRY) @@ -186,13 +181,27 @@ QQnxIntegration::QQnxIntegration() m_services = new QQnxServices(m_navigator); #if defined(Q_OS_BLACKBERRY) - m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, m_screenEventHandler); + QQnxVirtualKeyboardBps* virtualKeyboardBps = new QQnxVirtualKeyboardBps; + m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, m_screenEventHandler, virtualKeyboardBps); Q_FOREACH (QQnxScreen *screen, m_screens) m_bpsEventFilter->registerForScreenEvents(screen); m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher); + + m_virtualKeyboard = virtualKeyboardBps; #endif + if (m_virtualKeyboard) { + // TODO check if we need to do this for all screens or only the primary one + QObject::connect(m_virtualKeyboard, SIGNAL(heightChanged(int)), + primaryDisplay(), SLOT(keyboardHeightChanged(int))); + +#if defined(QQNX_PPS) + // Set up the input context + m_inputContext = new QQnxInputContext(*m_virtualKeyboard); +#endif + } + } QQnxIntegration::~QQnxIntegration() diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp deleted file mode 100644 index 685e5f0f0b..0000000000 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2011 - 2012 Research In Motion -** Contact: http://www.qt-project.org/ -** -** 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 "qqnxvirtualkeyboard.h" -#include "qqnxscreen.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -const char *QQnxVirtualKeyboard::ms_PPSPath = "/pps/services/input/control"; -const size_t QQnxVirtualKeyboard::ms_bufferSize = 2048; - -// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP. -#define KEYBOARD_SHADOW_HEIGHT 8 - -QQnxVirtualKeyboard::QQnxVirtualKeyboard() - : m_encoder(0), - m_decoder(0), - m_buffer(0), - m_fd(-1), - m_readNotifier(0) -{ -} - -QQnxVirtualKeyboard::~QQnxVirtualKeyboard() -{ - close(); -} - -void QQnxVirtualKeyboard::start() -{ -#ifdef QQNXVIRTUALKEYBOARD_DEBUG - qDebug() << "QQNX: starting keyboard event processing"; -#endif - if (!connect()) - return; -} - -void QQnxVirtualKeyboard::applyKeyboardMode(KeyboardMode mode) -{ - applyKeyboardModeOptions(mode); -} - -void QQnxVirtualKeyboard::close() -{ - delete m_readNotifier; - m_readNotifier = 0; - - if (m_fd != -1) { - ::close(m_fd); - m_fd = -1; - } - - if (m_decoder) { - pps_decoder_cleanup(m_decoder); - delete m_decoder; - m_decoder = 0; - } - - if (m_encoder) { - pps_encoder_cleanup(m_encoder); - delete m_encoder; - m_encoder = 0; - } - - delete [] m_buffer; - m_buffer = 0; -} - -bool QQnxVirtualKeyboard::connect() -{ - close(); - - m_encoder = new pps_encoder_t; - m_decoder = new pps_decoder_t; - - pps_encoder_initialize(m_encoder, false); - pps_decoder_initialize(m_decoder, NULL); - - errno = 0; - m_fd = ::open(ms_PPSPath, O_RDWR); - if (m_fd == -1) - { - qCritical("QQnxVirtualKeyboard: Unable to open \"%s\" for keyboard: %s (%d).", - ms_PPSPath, strerror(errno), errno); - close(); - return false; - } - - m_buffer = new char[ms_bufferSize]; - if (!m_buffer) { - qCritical("QQnxVirtualKeyboard: Unable to allocate buffer of %d bytes. Size is unavailable.", ms_bufferSize); - return false; - } - - if (!queryPPSInfo()) - return false; - - m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(ppsDataReady())); - - return true; -} - -bool QQnxVirtualKeyboard::queryPPSInfo() -{ - // Request info, requires id to regenerate res message. - pps_encoder_add_string(m_encoder, "msg", "info"); - pps_encoder_add_string(m_encoder, "id", "libWebView"); - - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - return false; - } - - pps_encoder_reset(m_encoder); - - return true; -} - -void QQnxVirtualKeyboard::ppsDataReady() -{ - ssize_t nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1); - -#ifdef QQNXVIRTUALKEYBOARD_DEBUG - qDebug() << "QQNX: keyboardMessage size: " << nread; -#endif - if (nread < 0){ - connect(); // reconnect - return; - } - - // We sometimes get spurious read notifications when no data is available. - // Bail out early in this case - if (nread == 0) - return; - - // nread is the real space necessary, not the amount read. - if (static_cast(nread) > ms_bufferSize - 1) { - qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1); - connect(); // reconnect - return; - } - - m_buffer[nread] = 0; - pps_decoder_parse_pps_str(m_decoder, m_buffer); - pps_decoder_push(m_decoder, NULL); -#ifdef QQNXVIRTUALKEYBOARD_DEBUG - pps_decoder_dump_tree(m_decoder, stderr); -#endif - - const char *value; - if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) { - qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]"); - return; - } - - if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) { - if (strcmp(value, "show") == 0) { - setVisible(true); - } else if (strcmp(value, "hide") == 0) { - setVisible(false); - } else if (strcmp(value, "info") == 0) - handleKeyboardInfoMessage(); - else if (strcmp(value, "connect") == 0) { } - else - qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]"); - } else if (pps_decoder_get_string(m_decoder, "res", &value) == PPS_DECODER_OK) { - if (strcmp(value, "info") == 0) - handleKeyboardInfoMessage(); - else - qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]"); - } else - qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS message type"); -} - -void QQnxVirtualKeyboard::handleKeyboardInfoMessage() -{ - int newHeight = 0; - const char *value; - - if (pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK) { - qCritical("QQnxVirtualKeyboard: Keyboard PPS dat object not found"); - return; - } - if (pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK) { - qCritical("QQnxVirtualKeyboard: Keyboard PPS size field not found"); - return; - } - if (pps_decoder_push(m_decoder, "locale") != PPS_DECODER_OK) { - qCritical("QQnxVirtualKeyboard: Keyboard PPS locale object not found"); - return; - } - if (pps_decoder_get_string(m_decoder, "languageId", &value) != PPS_DECODER_OK) { - qCritical("QQnxVirtualKeyboard: Keyboard PPS languageId field not found"); - return; - } - const QString languageId = QString::fromLatin1(value); - if (pps_decoder_get_string(m_decoder, "countryId", &value) != PPS_DECODER_OK) { - qCritical("QQnxVirtualKeyboard: Keyboard PPS size countryId not found"); - return; - } - const QString countryId = QString::fromLatin1(value); - - // HUGE hack, should be removed ASAP. - newHeight -= KEYBOARD_SHADOW_HEIGHT; // We want to ignore the 8 pixel shadow above the keyboard. (PR 88400) - - setHeight(newHeight); - - const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId); - setLocale(locale); - -#ifdef QQNXVIRTUALKEYBOARD_DEBUG - qDebug() << "QQNX: handleKeyboardInfoMessage size=" << newHeight << "locale=" << locale; -#endif -} - -bool QQnxVirtualKeyboard::showKeyboard() -{ -#ifdef QQNXVIRTUALKEYBOARD_DEBUG - qDebug() << "QQNX: showKeyboard()"; -#endif - - // Try to connect. - if (m_fd == -1 && !connect()) - return false; - - // NOTE: This must be done everytime the keyboard is shown even if there is no change because - // hiding the keyboard wipes the setting. - applyKeyboardModeOptions(keyboardMode()); - - if (isVisible()) - return true; - - pps_encoder_reset(m_encoder); - - // Send the show message. - pps_encoder_add_string(m_encoder, "msg", "show"); - - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - return false; - } - - pps_encoder_reset(m_encoder); - - // Return true if no error occurs. Sizing response will be triggered when confirmation of - // the change arrives. - return true; -} - -bool QQnxVirtualKeyboard::hideKeyboard() -{ -#ifdef QQNXVIRTUALKEYBOARD_DEBUG - qDebug() << "QQNX: hideKeyboard()"; -#endif - - if (m_fd == -1 && !connect()) - return false; - - pps_encoder_add_string(m_encoder, "msg", "hide"); - - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - - //Try again. - if (connect()) { - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - return false; - } - } - else - return false; - } - - pps_encoder_reset(m_encoder); - - // Return true if no error occurs. Sizing response will be triggered when confirmation of - // the change arrives. - return true; -} - -void QQnxVirtualKeyboard::applyKeyboardModeOptions(KeyboardMode mode) -{ - // Try to connect. - if (m_fd == -1 && !connect()) - return; - - // Send the options message. - pps_encoder_add_string(m_encoder, "msg", "options"); - - pps_encoder_start_object(m_encoder, "dat"); - switch (mode) { - case Url: - addUrlModeOptions(); - break; - case Email: - addEmailModeOptions(); - break; - case Web: - addWebModeOptions(); - break; - case NumPunc: - addNumPuncModeOptions(); - break; - case Symbol: - addSymbolModeOptions(); - break; - case Phone: - addPhoneModeOptions(); - break; - case Pin: - addPinModeOptions(); - break; - case Default: - default: - addDefaultModeOptions(); - break; - } - - pps_encoder_end_object(m_encoder); - - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { - close(); - } - - pps_encoder_reset(m_encoder); -} - -void QQnxVirtualKeyboard::addDefaultModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "default"); -} - -void QQnxVirtualKeyboard::addUrlModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "url"); -} - -void QQnxVirtualKeyboard::addEmailModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "email"); -} - -void QQnxVirtualKeyboard::addWebModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "web"); -} - -void QQnxVirtualKeyboard::addNumPuncModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "numPunc"); -} - -void QQnxVirtualKeyboard::addPhoneModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "phone"); -} - -void QQnxVirtualKeyboard::addPinModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "pin"); -} - -void QQnxVirtualKeyboard::addSymbolModeOptions() -{ - pps_encoder_add_string(m_encoder, "enter", "enter.default"); - pps_encoder_add_string(m_encoder, "type", "symbol"); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h deleted file mode 100644 index b01a4df963..0000000000 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2011 - 2012 Research In Motion -** Contact: http://www.qt-project.org/ -** -** 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 VIRTUALKEYBOARD_H_ -#define VIRTUALKEYBOARD_H_ - -#include "qqnxabstractvirtualkeyboard.h" - -#include - -QT_BEGIN_NAMESPACE - -class QSocketNotifier; - -/* Shamelessly copied from the browser - this should be rewritten once we have a proper PPS wrapper class */ -class QQnxVirtualKeyboard : public QQnxAbstractVirtualKeyboard -{ - Q_OBJECT -public: - QQnxVirtualKeyboard(); - ~QQnxVirtualKeyboard(); - - bool showKeyboard(); - bool hideKeyboard(); - -public Q_SLOTS: - void start(); - -protected: - void applyKeyboardMode(KeyboardMode mode); - -private Q_SLOTS: - void ppsDataReady(); - -private: - // Will be called internally if needed. - bool connect(); - void close(); - bool queryPPSInfo(); - void handleKeyboardInfoMessage(); - - void applyKeyboardModeOptions(KeyboardMode mode); - void addDefaultModeOptions(); - void addUrlModeOptions(); - void addEmailModeOptions(); - void addWebModeOptions(); - void addNumPuncModeOptions(); - void addSymbolModeOptions(); - void addPhoneModeOptions(); - void addPinModeOptions(); - - pps_encoder_t *m_encoder; - pps_decoder_t *m_decoder; - char *m_buffer; - int m_fd; - QSocketNotifier *m_readNotifier; - - // Path to keyboardManager in PPS. - static const char *ms_PPSPath; - static const size_t ms_bufferSize; -}; - -#endif /* VIRTUALKEYBOARD_H_ */ diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp new file mode 100644 index 0000000000..3f0e5b2713 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp @@ -0,0 +1,209 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** 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 "qqnxvirtualkeyboardbps.h" + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QQnxVirtualKeyboardBps::QQnxVirtualKeyboardBps(QObject *parent) + : QQnxAbstractVirtualKeyboard(parent) +{ + if (locale_request_events(0) != BPS_SUCCESS) + qWarning("QQNX: Failed to register for locale events"); + + if (virtualkeyboard_request_events(0) != BPS_SUCCESS) + qWarning("QQNX: Failed to register for virtual keyboard events"); + + int height = 0; + if (virtualkeyboard_get_height(&height) != BPS_SUCCESS) + qWarning("QQNX: Failed to get virtual keyboard height"); + + setHeight(height); +} + +bool QQnxVirtualKeyboardBps::handleEvent(bps_event_t *event) +{ + const int eventDomain = bps_event_get_domain(event); + if (eventDomain == locale_get_domain()) + return handleLocaleEvent(event); + + if (eventDomain == virtualkeyboard_get_domain()) + return handleVirtualKeyboardEvent(event); + + return false; +} + +bool QQnxVirtualKeyboardBps::showKeyboard() +{ +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << Q_FUNC_INFO << "current visibility=" << isVisible(); +#endif + + virtualkeyboard_show(); + return true; +} + +bool QQnxVirtualKeyboardBps::hideKeyboard() +{ +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << Q_FUNC_INFO << "current visibility=" << isVisible(); +#endif + + virtualkeyboard_hide(); + return true; +} + +void QQnxVirtualKeyboardBps::applyKeyboardMode(KeyboardMode mode) +{ + virtualkeyboard_layout_t layout = VIRTUALKEYBOARD_LAYOUT_DEFAULT; + + switch (mode) { + case Url: + layout = VIRTUALKEYBOARD_LAYOUT_URL; + break; + + case Email: + layout = VIRTUALKEYBOARD_LAYOUT_EMAIL; + break; + + case Web: + layout = VIRTUALKEYBOARD_LAYOUT_WEB; + break; + + case NumPunc: + layout = VIRTUALKEYBOARD_LAYOUT_NUM_PUNC; + break; + + case Symbol: + layout = VIRTUALKEYBOARD_LAYOUT_SYMBOL; + break; + + case Phone: + layout = VIRTUALKEYBOARD_LAYOUT_PHONE; + break; + + case Pin: + layout = VIRTUALKEYBOARD_LAYOUT_PIN; + break; + + case Default: // fall through + default: + layout = VIRTUALKEYBOARD_LAYOUT_DEFAULT; + break; + } + +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << Q_FUNC_INFO << "mode=" << mode; +#endif + + virtualkeyboard_change_options(layout, VIRTUALKEYBOARD_ENTER_DEFAULT); +} + +bool QQnxVirtualKeyboardBps::handleLocaleEvent(bps_event_t *event) +{ + if (bps_event_get_code(event) == LOCALE_INFO) { + const QString language = QString::fromAscii(locale_event_get_language(event)); + const QString country = QString::fromAscii(locale_event_get_country(event)); + + const QLocale newLocale(language + QLatin1Char('_') + country); + +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << Q_FUNC_INFO << "current locale" << locale() << "new locale=" << newLocale; +#endif + setLocale(newLocale); + return true; + } + +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << "QQNX: Unhandled locale event. code=" << bps_event_get_code(event); +#endif + + return false; +} + +bool QQnxVirtualKeyboardBps::handleVirtualKeyboardEvent(bps_event_t *event) +{ + switch (bps_event_get_code(event)) { + case VIRTUALKEYBOARD_EVENT_VISIBLE: + #if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << Q_FUNC_INFO << "EVENT VISIBLE: current visibility=" << isVisible(); + #endif + + setVisible(true); + break; + + case VIRTUALKEYBOARD_EVENT_HIDDEN: + #if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << Q_FUNC_INFO << "EVENT HIDDEN: current visibility=" << isVisible(); + #endif + + setVisible(false); + break; + + case VIRTUALKEYBOARD_EVENT_INFO: { + const int newHeight = virtualkeyboard_event_get_height(event); + + #if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << Q_FUNC_INFO << "EVENT INFO: current height=" << height() << "new height=" << newHeight; + #endif + + setHeight(newHeight); + break; + } + + default: + #if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << "QQNX: Unhandled virtual keyboard event. code=" << bps_event_get_code(event); + #endif + + return false; + } + + return true; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h new file mode 100644 index 0000000000..0fc95aad50 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.h @@ -0,0 +1,72 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** 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 QQNXVIRTUALKEYBOARDBPS_H +#define QQNXVIRTUALKEYBOARDBPS_H + +#include "qqnxabstractvirtualkeyboard.h" + +struct bps_event_t; + +QT_BEGIN_NAMESPACE + +class QQnxVirtualKeyboardBps : public QQnxAbstractVirtualKeyboard +{ + Q_OBJECT +public: + explicit QQnxVirtualKeyboardBps(QObject *parent = 0); + + bool handleEvent(bps_event_t *event); + + bool showKeyboard(); + bool hideKeyboard(); + +protected: + void applyKeyboardMode(KeyboardMode mode); + +private: + bool handleLocaleEvent(bps_event_t *event); + bool handleVirtualKeyboardEvent(bps_event_t *event); +}; + +QT_END_NAMESPACE + +#endif // QQNXVIRTUALKEYBOARDBPS_H diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp new file mode 100644 index 0000000000..d139e7f66b --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp @@ -0,0 +1,430 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** 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 "qqnxvirtualkeyboardpps.h" +#include "qqnxscreen.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +const char *QQnxVirtualKeyboardPps::ms_PPSPath = "/pps/services/input/control"; +const size_t QQnxVirtualKeyboardPps::ms_bufferSize = 2048; + +// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP. +#define KEYBOARD_SHADOW_HEIGHT 8 + +QQnxVirtualKeyboardPps::QQnxVirtualKeyboardPps() + : m_encoder(0), + m_decoder(0), + m_buffer(0), + m_fd(-1), + m_readNotifier(0) +{ +} + +QQnxVirtualKeyboardPps::~QQnxVirtualKeyboardPps() +{ + close(); +} + +void QQnxVirtualKeyboardPps::start() +{ +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << "QQNX: starting keyboard event processing"; +#endif + if (!connect()) + return; +} + +void QQnxVirtualKeyboardPps::applyKeyboardMode(KeyboardMode mode) +{ + applyKeyboardModeOptions(mode); +} + +void QQnxVirtualKeyboardPps::close() +{ + delete m_readNotifier; + m_readNotifier = 0; + + if (m_fd != -1) { + ::close(m_fd); + m_fd = -1; + } + + if (m_decoder) { + pps_decoder_cleanup(m_decoder); + delete m_decoder; + m_decoder = 0; + } + + if (m_encoder) { + pps_encoder_cleanup(m_encoder); + delete m_encoder; + m_encoder = 0; + } + + delete [] m_buffer; + m_buffer = 0; +} + +bool QQnxVirtualKeyboardPps::connect() +{ + close(); + + m_encoder = new pps_encoder_t; + m_decoder = new pps_decoder_t; + + pps_encoder_initialize(m_encoder, false); + pps_decoder_initialize(m_decoder, NULL); + + errno = 0; + m_fd = ::open(ms_PPSPath, O_RDWR); + if (m_fd == -1) + { + qCritical("QQnxVirtualKeyboard: Unable to open \"%s\" for keyboard: %s (%d).", + ms_PPSPath, strerror(errno), errno); + close(); + return false; + } + + m_buffer = new char[ms_bufferSize]; + if (!m_buffer) { + qCritical("QQnxVirtualKeyboard: Unable to allocate buffer of %d bytes. Size is unavailable.", ms_bufferSize); + return false; + } + + if (!queryPPSInfo()) + return false; + + m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); + QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(ppsDataReady())); + + return true; +} + +bool QQnxVirtualKeyboardPps::queryPPSInfo() +{ + // Request info, requires id to regenerate res message. + pps_encoder_add_string(m_encoder, "msg", "info"); + pps_encoder_add_string(m_encoder, "id", "libWebView"); + + if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { + close(); + return false; + } + + pps_encoder_reset(m_encoder); + + return true; +} + +void QQnxVirtualKeyboardPps::ppsDataReady() +{ + ssize_t nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1); + +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << "QQNX: keyboardMessage size: " << nread; +#endif + if (nread < 0){ + connect(); // reconnect + return; + } + + // We sometimes get spurious read notifications when no data is available. + // Bail out early in this case + if (nread == 0) + return; + + // nread is the real space necessary, not the amount read. + if (static_cast(nread) > ms_bufferSize - 1) { + qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1); + connect(); // reconnect + return; + } + + m_buffer[nread] = 0; + pps_decoder_parse_pps_str(m_decoder, m_buffer); + pps_decoder_push(m_decoder, NULL); +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + pps_decoder_dump_tree(m_decoder, stderr); +#endif + + const char *value; + if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) { + qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]"); + return; + } + + if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) { + if (strcmp(value, "show") == 0) { + setVisible(true); + } else if (strcmp(value, "hide") == 0) { + setVisible(false); + } else if (strcmp(value, "info") == 0) + handleKeyboardInfoMessage(); + else if (strcmp(value, "connect") == 0) { } + else + qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]"); + } else if (pps_decoder_get_string(m_decoder, "res", &value) == PPS_DECODER_OK) { + if (strcmp(value, "info") == 0) + handleKeyboardInfoMessage(); + else + qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]"); + } else + qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS message type"); +} + +void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage() +{ + int newHeight = 0; + const char *value; + + if (pps_decoder_push(m_decoder, "dat") != PPS_DECODER_OK) { + qCritical("QQnxVirtualKeyboard: Keyboard PPS dat object not found"); + return; + } + if (pps_decoder_get_int(m_decoder, "size", &newHeight) != PPS_DECODER_OK) { + qCritical("QQnxVirtualKeyboard: Keyboard PPS size field not found"); + return; + } + if (pps_decoder_push(m_decoder, "locale") != PPS_DECODER_OK) { + qCritical("QQnxVirtualKeyboard: Keyboard PPS locale object not found"); + return; + } + if (pps_decoder_get_string(m_decoder, "languageId", &value) != PPS_DECODER_OK) { + qCritical("QQnxVirtualKeyboard: Keyboard PPS languageId field not found"); + return; + } + const QString languageId = QString::fromLatin1(value); + if (pps_decoder_get_string(m_decoder, "countryId", &value) != PPS_DECODER_OK) { + qCritical("QQnxVirtualKeyboard: Keyboard PPS size countryId not found"); + return; + } + const QString countryId = QString::fromLatin1(value); + + // HUGE hack, should be removed ASAP. + newHeight -= KEYBOARD_SHADOW_HEIGHT; // We want to ignore the 8 pixel shadow above the keyboard. (PR 88400) + + setHeight(newHeight); + + const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId); + setLocale(locale); + +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << "QQNX: handleKeyboardInfoMessage size=" << newHeight << "locale=" << locale; +#endif +} + +bool QQnxVirtualKeyboardPps::showKeyboard() +{ +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << "QQNX: showKeyboard()"; +#endif + + // Try to connect. + if (m_fd == -1 && !connect()) + return false; + + // NOTE: This must be done everytime the keyboard is shown even if there is no change because + // hiding the keyboard wipes the setting. + applyKeyboardModeOptions(keyboardMode()); + + if (isVisible()) + return true; + + pps_encoder_reset(m_encoder); + + // Send the show message. + pps_encoder_add_string(m_encoder, "msg", "show"); + + if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { + close(); + return false; + } + + pps_encoder_reset(m_encoder); + + // Return true if no error occurs. Sizing response will be triggered when confirmation of + // the change arrives. + return true; +} + +bool QQnxVirtualKeyboardPps::hideKeyboard() +{ +#if defined(QQNXVIRTUALKEYBOARD_DEBUG) + qDebug() << "QQNX: hideKeyboard()"; +#endif + + if (m_fd == -1 && !connect()) + return false; + + pps_encoder_add_string(m_encoder, "msg", "hide"); + + if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { + close(); + + //Try again. + if (connect()) { + if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { + close(); + return false; + } + } + else + return false; + } + + pps_encoder_reset(m_encoder); + + // Return true if no error occurs. Sizing response will be triggered when confirmation of + // the change arrives. + return true; +} + +void QQnxVirtualKeyboardPps::applyKeyboardModeOptions(KeyboardMode mode) +{ + // Try to connect. + if (m_fd == -1 && !connect()) + return; + + // Send the options message. + pps_encoder_add_string(m_encoder, "msg", "options"); + + pps_encoder_start_object(m_encoder, "dat"); + switch (mode) { + case Url: + addUrlModeOptions(); + break; + case Email: + addEmailModeOptions(); + break; + case Web: + addWebModeOptions(); + break; + case NumPunc: + addNumPuncModeOptions(); + break; + case Symbol: + addSymbolModeOptions(); + break; + case Phone: + addPhoneModeOptions(); + break; + case Pin: + addPinModeOptions(); + break; + case Default: + default: + addDefaultModeOptions(); + break; + } + + pps_encoder_end_object(m_encoder); + + if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { + close(); + } + + pps_encoder_reset(m_encoder); +} + +void QQnxVirtualKeyboardPps::addDefaultModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "default"); +} + +void QQnxVirtualKeyboardPps::addUrlModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "url"); +} + +void QQnxVirtualKeyboardPps::addEmailModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "email"); +} + +void QQnxVirtualKeyboardPps::addWebModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "web"); +} + +void QQnxVirtualKeyboardPps::addNumPuncModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "numPunc"); +} + +void QQnxVirtualKeyboardPps::addPhoneModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "phone"); +} + +void QQnxVirtualKeyboardPps::addPinModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "pin"); +} + +void QQnxVirtualKeyboardPps::addSymbolModeOptions() +{ + pps_encoder_add_string(m_encoder, "enter", "enter.default"); + pps_encoder_add_string(m_encoder, "type", "symbol"); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.h b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.h new file mode 100644 index 0000000000..abcf411fed --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.h @@ -0,0 +1,100 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** 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 VIRTUALKEYBOARDPPS_H_ +#define VIRTUALKEYBOARDPPS_H_ + +#include "qqnxabstractvirtualkeyboard.h" + +#include + +QT_BEGIN_NAMESPACE + +class QSocketNotifier; + +class QQnxVirtualKeyboardPps : public QQnxAbstractVirtualKeyboard +{ + Q_OBJECT +public: + QQnxVirtualKeyboardPps(); + ~QQnxVirtualKeyboardPps(); + + bool showKeyboard(); + bool hideKeyboard(); + +public Q_SLOTS: + void start(); + +protected: + void applyKeyboardMode(KeyboardMode mode); + +private Q_SLOTS: + void ppsDataReady(); + +private: + // Will be called internally if needed. + bool connect(); + void close(); + bool queryPPSInfo(); + void handleKeyboardInfoMessage(); + + void applyKeyboardModeOptions(KeyboardMode mode); + void addDefaultModeOptions(); + void addUrlModeOptions(); + void addEmailModeOptions(); + void addWebModeOptions(); + void addNumPuncModeOptions(); + void addSymbolModeOptions(); + void addPhoneModeOptions(); + void addPinModeOptions(); + + pps_encoder_t *m_encoder; + pps_decoder_t *m_decoder; + char *m_buffer; + int m_fd; + QSocketNotifier *m_readNotifier; + + // Path to keyboardManager in PPS. + static const char *ms_PPSPath; + static const size_t ms_bufferSize; +}; + +#endif /* VIRTUALKEYBOARDPPS_H_ */ -- cgit v1.2.3