[PATCH] arora - Provide the Qtopia "WebAccess" service
Neil Jerram
neil at ossau.homelinux.net
Mon Sep 17 00:42:19 CEST 2012
This makes clicking on links in email work - both when Arora is
already running, and when there isn't already any web browser
running (in which case Arora is started automatically).
---
.gitignore | 2 +-
src/browserapplication.cpp | 29 +++++++++++++++++++++++++++++
src/qbuild.pro | 6 ++++++
src/services/WebAccess/arora | 2 ++
src/webservice.h | 37 +++++++++++++++++++++++++++++++++++++
5 files changed, 75 insertions(+), 1 deletion(-)
create mode 100644 src/services/WebAccess/arora
create mode 100644 src/webservice.h
diff --git a/.gitignore b/.gitignore
index b101154..a8bea3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-arora
+/arora
Arora.app
Makefile
.DS_Store
diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp
index cc8bd1f..5585971 100644
--- a/src/browserapplication.cpp
+++ b/src/browserapplication.cpp
@@ -83,9 +83,23 @@
#include <qwebsettings.h>
#include <QtopiaApplication>
+#include <QtopiaAbstractService>
#include <qdebug.h>
+#include "webservice.h"
+
+void WebAccessService::openURL(QString url)
+{
+ emit openUrl(url);
+}
+
+void WebAccessService::openSecureURL(QString url)
+{
+ // XXX make sure this is a secure url
+ emit openUrl(url);
+}
+
DownloadManager *BrowserApplication::s_downloadManager = 0;
HistoryManager *BrowserApplication::s_historyManager = 0;
NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0;
@@ -152,6 +166,10 @@ BrowserApplication::BrowserApplication(int &argc, char **argv)
this, SLOT(lastWindowClosed()));
#endif
+ QObject *service = new WebAccessService(this);
+ connect(service, SIGNAL(openUrl(const QString &)),
+ this, SLOT(messageRecieved(const QString &)));
+
#ifndef AUTOTESTS
QTimer::singleShot(0, this, SLOT(postLaunch()));
#endif
@@ -455,6 +473,17 @@ BrowserMainWindow *BrowserApplication::newMainWindow()
m_mainWindows.prepend(browser);
setMainWidget(browser); //
showMainWidget();
+
+ // Calling showMainWidget() a second time is the magic sauce that
+ // is needed for Qtopia not to kill Arora after it has processed a
+ // request for the WebAccess service. When servicing a
+ // QtopiaServiceRequest requires _launching_ a new application -
+ // i.e. because a suitable application isn't already running -
+ // Qtopia's default behaviour is to close the launched application
+ // again as soon as it appears to have processed that request.
+ // For a web browser, we clearly don't want that.
+ showMainWidget();
+
// browser->show();
return browser;
}
diff --git a/src/qbuild.pro b/src/qbuild.pro
index 4db82b6..7e39289 100644
--- a/src/qbuild.pro
+++ b/src/qbuild.pro
@@ -93,6 +93,7 @@ HEADERS += \
tabwidget.h \
toolbarsearch.h \
webactionmapper.h \
+ webservice.h \
webview.h \
webviewsearch.h \
xbel.h
@@ -151,3 +152,8 @@ SOURCES += \
utils/rotate.cpp
#-----------------------------------------------
+
+# Install service registration
+service.files=services/WebAccess/arora
+service.path=/services/WebAccess
+INSTALLS+=service
diff --git a/src/services/WebAccess/arora b/src/services/WebAccess/arora
new file mode 100644
index 0000000..f99c0fd
--- /dev/null
+++ b/src/services/WebAccess/arora
@@ -0,0 +1,2 @@
+[Standard]
+Version=100
diff --git a/src/webservice.h b/src/webservice.h
new file mode 100644
index 0000000..d164a68
--- /dev/null
+++ b/src/webservice.h
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** This file was largely copied from examples/webviewer/webviewer.cpp
+** in the QtMoko distribution. But given that it has so few lines of
+** code, and that that code simply implements what standard Qtopia
+** documentation says for a Qtopia service, I don't think it has to
+** inherit that file's copyright and license. For the same reasons,
+** we don't declare any specific copyright and license for this file.
+**
+****************************************************************************/
+
+#ifndef WEBSERVICE_H
+#define WEBSERVICE_H
+
+#include <qobject.h>
+#include <qtopiaabstractservice.h>
+#include <qstring.h>
+
+class WebAccessService : public QtopiaAbstractService
+{
+ Q_OBJECT
+
+public:
+ WebAccessService(QObject* parent) : QtopiaAbstractService("WebAccess",parent)
+ {
+ publishAll();
+ }
+
+signals:
+ void openUrl(const QString &);
+
+public slots:
+ void openURL(QString);
+ void openSecureURL(QString);
+};
+
+#endif
--
1.7.10.4
--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
filename=0001-mokofaen-allow-space-for-indicating-10-or-more-satel.patch
Content-Transfer-Encoding: 8bit
More information about the community
mailing list