Initial implementation of QQnxServices
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>
Mon, 19 Mar 2012 16:13:13 +0000 (17:13 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Mar 2012 20:53:53 +0000 (21:53 +0100)
Extends platform services for QNX devices.

Change-Id: I1eb685cdb38591cd73eaaf40ffb5691db0142953
Reviewed-by: Jeff Kehres <jkehres@rim.com>
Reviewed-by: Sean Harmer <sh@theharmers.co.uk>
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
src/plugins/platforms/qnx/qnx.pro
src/plugins/platforms/qnx/qqnxintegration.cpp
src/plugins/platforms/qnx/qqnxintegration.h
src/plugins/platforms/qnx/qqnxservices.cpp [new file with mode: 0644]
src/plugins/platforms/qnx/qqnxservices.h [new file with mode: 0644]

index cf82084..588464f 100644 (file)
@@ -37,6 +37,7 @@ SOURCES =   main.cpp \
             qqnxclipboard.cpp \
             qqnxrootwindow.cpp
 
+
 HEADERS =   qqnxbuffer.h \
             qqnxeventthread.h \
             qqnxkeytranslator.h \
@@ -51,6 +52,11 @@ HEADERS =   qqnxbuffer.h \
             qqnxclipboard.h \
             qqnxrootwindow.h
 
+CONFIG(blackberry) {
+    SOURCES += qqnxservices.cpp
+    HEADERS += qqnxservices.h
+}
+
 CONFIG(qqnx_imf) {
     DEFINES += QQNX_IMF
     HEADERS += qqnxinputcontext_imf.h
@@ -64,6 +70,10 @@ QMAKE_CXXFLAGS += -I./private
 
 LIBS += -lpps -lscreen -lEGL -lclipboard
 
+CONFIG(blackberry) {
+    LIBS += -lbps
+}
+
 include (../../../platformsupport/eglconvenience/eglconvenience.pri)
 include (../../../platformsupport/fontdatabases/fontdatabases.pri)
 
index cb7f14f..5ef34f3 100644 (file)
@@ -50,6 +50,7 @@
 #include "qqnxvirtualkeyboard.h"
 #include "qqnxclipboard.h"
 #include "qqnxglcontext.h"
+#include "qqnxservices.h"
 
 #if defined(QQnx_IMF)
 #include "qqnxinputcontext_imf.h"
@@ -82,6 +83,7 @@ QQnxIntegration::QQnxIntegration()
     , m_fontDatabase(new QGenericUnixFontDatabase())
     , m_paintUsingOpenGL(false)
     , m_eventDispatcher(createUnixEventDispatcher())
+    , m_services(0)
 #ifndef QT_NO_CLIPBOARD
     , m_clipboard(0)
 #endif
@@ -124,6 +126,11 @@ QQnxIntegration::QQnxIntegration()
 
     // Set up the input context
     m_inputContext = new QQnxInputContext;
+
+    // Create services handling class
+#ifdef Q_OS_BLACKBERRY
+    m_services = new QQnxServices;
+#endif
 }
 
 QQnxIntegration::~QQnxIntegration()
@@ -154,6 +161,11 @@ QQnxIntegration::~QQnxIntegration()
     // Cleanup global OpenGL resources
     QQnxGLContext::shutdown();
 
+    // Destroy services class
+#ifdef Q_OS_BLACKBERRY
+    delete m_services;
+#endif
+
 #if defined(QQNXINTEGRATION_DEBUG)
     qDebug() << "QQnx: platform plugin shutdown end";
 #endif
@@ -266,6 +278,11 @@ QVariant QQnxIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
     return QPlatformIntegration::styleHint(hint);
 }
 
+QPlatformServices * QQnxIntegration::services() const
+{
+    return m_services;
+}
+
 QWindow *QQnxIntegration::window(screen_window_t qnxWindow)
 {
 #if defined(QQNXINTEGRATION_DEBUG)
index 892bb6e..6aa1610 100644 (file)
@@ -54,6 +54,7 @@ class QQnxEventThread;
 class QQnxInputContext;
 class QQnxNavigatorEventHandler;
 class QQnxWindow;
+class QQnxServices;
 
 #ifndef QT_NO_CLIPBOARD
 class QQnxClipboard;
@@ -91,6 +92,8 @@ public:
 
     bool paintUsingOpenGL() const { return m_paintUsingOpenGL; }
 
+    virtual QPlatformServices *services() const;
+
     static QWindow *window(screen_window_t qnxWindow);
 
 private:
@@ -104,6 +107,7 @@ private:
     QPlatformFontDatabase *m_fontDatabase;
     bool m_paintUsingOpenGL;
     QAbstractEventDispatcher *m_eventDispatcher;
+    QQnxServices *m_services;
 #ifndef QT_NO_CLIPBOARD
     mutable QQnxClipboard* m_clipboard;
 #endif
diff --git a/src/plugins/platforms/qnx/qqnxservices.cpp b/src/plugins/platforms/qnx/qqnxservices.cpp
new file mode 100644 (file)
index 0000000..a1a2790
--- /dev/null
@@ -0,0 +1,81 @@
+/***************************************************************************
+**
+** 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 "qqnxservices.h"
+
+#include <bps/navigator.h>
+#include <stdbool.h>
+#include <sys/platform.h>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+QQnxServices::QQnxServices()
+{
+    bps_initialize();
+}
+
+QQnxServices::~QQnxServices()
+{
+    bps_shutdown();
+}
+
+bool QQnxServices::openUrl(const QUrl &url)
+{
+    return navigatorInvoke(url);
+}
+
+bool QQnxServices::openDocument(const QUrl &url)
+{
+    return navigatorInvoke(url);
+}
+
+bool QQnxServices::navigatorInvoke(const QUrl &url)
+{
+    if (!url.isValid() || url.isRelative())
+        return false;
+
+    int ret = navigator_invoke(url.toString().toUtf8(), 0);
+
+    return (ret == BPS_SUCCESS);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxservices.h b/src/plugins/platforms/qnx/qqnxservices.h
new file mode 100644 (file)
index 0000000..36eb8ed
--- /dev/null
@@ -0,0 +1,64 @@
+/***************************************************************************
+**
+** 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 QQNXSERVICES_H
+#define QQNXSERVICES_H
+
+#include <QtGui/QPlatformServices>
+
+QT_BEGIN_NAMESPACE
+
+class QQnxServices : public QPlatformServices
+{
+public:
+    QQnxServices();
+    ~QQnxServices();
+
+    bool openUrl(const QUrl &url);
+    bool openDocument(const QUrl &url);
+
+private:
+    bool navigatorInvoke(const QUrl &url);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQNXSERVICES_H