summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/browserdbus.cpp124
-rw-r--r--common/browserdbus.h32
-rw-r--r--common/browserdefs.h141
-rw-r--r--common/errorloggerdbus.cpp101
-rw-r--r--common/errorloggerdbus.h37
5 files changed, 427 insertions, 8 deletions
diff --git a/common/browserdbus.cpp b/common/browserdbus.cpp
index 9c2bf02..f604963 100644
--- a/common/browserdbus.cpp
+++ b/common/browserdbus.cpp
@@ -19,7 +19,9 @@
#include "../common/browserdefs.h"
BrowserDbus::BrowserDbus(QObject *parent) :
- QObject(parent), m_instanceId("1"), m_isconnected(false)
+ QObject(parent), m_instanceId("1"), m_isconnected(false), bookmark(NULL),
+ userinput(NULL), webpagewindow(NULL), actualtab(NULL),
+ actualuserinput(NULL),browser(NULL), dbusservicename(NULL)
{
qDebug() << __PRETTY_FUNCTION__;
@@ -39,6 +41,9 @@ void BrowserDbus::registertypes() {
qDBusRegisterMetaType<conn::brw::BrowserActions>();
qDBusRegisterMetaType<conn::brw::OBJECT_HANDLE>();
qDBusRegisterMetaType<conn::brw::ObjectHandleList>();
+ qDBusRegisterMetaType<conn::brw::AuthenticationData>();
+ qDBusRegisterMetaType<conn::brw::SSL_ERROR>();
+ qDBusRegisterMetaType<conn::brw::SslError>();
}
void BrowserDbus::connectdbussession(QString id) {
@@ -211,10 +216,30 @@ void BrowserDbus::createPageWindow(int deviceid, int x, int y, int width, int he
inputhash.insert(handle, userinput);
actualuserinput = userinput;
+ connect(actualuserinput, SIGNAL(onAlertDialog(QString)), this, SIGNAL(onAlertDialog(QString)));
+ connect(actualuserinput, SIGNAL(onConfirmDialog(QString)), this, SIGNAL(onConfirmDialog(QString)));
+ connect(actualuserinput, SIGNAL(onPromptDialog(QString,QString)),this, SIGNAL(onPromptDialog(QString,QString)));
+ connect(actualuserinput, SIGNAL(onDialogCanceled(void)), this, SIGNAL(onDialogCanceled()));
+ connect(actualuserinput, SIGNAL(onSelect(const QString &, const conn::brw::SelectableOptionList &, bool)), this, SIGNAL (onSelect(const QString &, const conn::brw::SelectableOptionList &, bool)));
+
if(!actualuserinput->isValid())
qDebug() << "failed create object /Browser/IWebPageWindow*/IUserInput";
connect(actualuserinput, SIGNAL(onInputText(QString,QString,conn::brw::INPUT_ELEMENT_TYPE,int,int,int,int)), this, SLOT(InputTextReceived(QString,QString,conn::brw::INPUT_ELEMENT_TYPE,int,int,int,int)));
+
+ QString *networkmanagerservice = new QString(*webpagewindowservice + "/INetworkManager");
+
+ networkmanager = new conn::brw::INetworkManager(*dbusservicename, *networkmanagerservice,
+ QDBusConnection::sessionBus(), this);
+
+ connect(networkmanager, SIGNAL(onAuthenticationDialog(const conn::brw::AuthenticationData&)),
+ this, SIGNAL(onAuthenticationDialog(const conn::brw::AuthenticationData&)));
+ connect(networkmanager, SIGNAL(onSslErrorDialog(const conn::brw::SslError&)),
+ this, SIGNAL(onSslErrorDialog(const conn::brw::SslError&)));
+ connect(networkmanager, SIGNAL(onSslErrorDialogCancel(const conn::brw::SslError&)),
+ this, SIGNAL(onSslErrorDialogCancel(const conn::brw::SslError&)));
+ connect(networkmanager, SIGNAL(onAuthenticationDialogCancel(const conn::brw::AuthenticationData&)),
+ this, SIGNAL(onAuthenticationDialogCancel(const conn::brw::AuthenticationData&)));
} else {
QDBusError error = reply.error();
qDebug() << "ERROR " << error.name() << error.message();
@@ -283,6 +308,57 @@ void BrowserDbus::inputText(conn::brw::DIALOG_RESULT a_eResult, QString a_strInp
}
}
+void BrowserDbus::closeAlertDialog()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QDBusPendingReply<conn::brw::ERROR_IDS> reply = actualuserinput->closeAlertDialog();
+
+ reply.waitForFinished();
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+}
+
+void BrowserDbus::closeConfirmDialog(conn::brw::DIALOG_RESULT d)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QDBusPendingReply<conn::brw::ERROR_IDS> reply = actualuserinput->closeConfirmDialog(d);
+
+ reply.waitForFinished();
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+}
+
+void BrowserDbus::closePromptDialog(QString s, conn::brw::DIALOG_RESULT d)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QDBusPendingReply<conn::brw::ERROR_IDS> reply = actualuserinput->closePromptDialog(s,d);
+
+ reply.waitForFinished();
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+}
+
void BrowserDbus::InputTextReceived(QString a_strInputName, QString a_strDefaultInputValue, conn::brw::INPUT_ELEMENT_TYPE a_i32InputValueType, int a_s32MaxLength, int a_s32Max, int a_s32Min, int a_s32Step) {
qDebug() << __PRETTY_FUNCTION__ << a_strInputName << a_strDefaultInputValue << a_i32InputValueType << a_s32MaxLength << a_s32Max << a_s32Min << a_s32Step;
}
@@ -661,3 +737,49 @@ void BrowserDbus::select() {
qDebug() << "ERROR " << error.name() << error.message();
}
}
+
+QStringList BrowserDbus::getPrevEnteredValues(QString name, QString value, conn::brw::INPUT_ELEMENT_TYPE type)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ QStringList list;
+
+ QDBusReply<conn::brw::ERROR_IDS> reply = actualuserinput->getPrevEnteredValues(name, value, type, list);
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+ return list;
+}
+
+void BrowserDbus::closeAuthenticationDialog(conn::brw::DIALOG_RESULT r, const conn::brw::AuthenticationData& d)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ QStringList list;
+
+ QDBusReply<conn::brw::ERROR_IDS> reply = networkmanager->closeAuthenticationDialog(r,d);
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+}
+
+void BrowserDbus::closeSslErrorDialog(conn::brw::DIALOG_RESULT r, bool b)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ QStringList list;
+
+ QDBusReply<conn::brw::ERROR_IDS> reply = networkmanager->closeSslErrorDialog(r,b);
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+}
diff --git a/common/browserdbus.h b/common/browserdbus.h
index 0d7b73f..8cb6250 100644
--- a/common/browserdbus.h
+++ b/common/browserdbus.h
@@ -21,6 +21,7 @@
#include "iuserinput_interface.h"
#include "iwebpagewindow_interface.h"
#include "ibrowser_interface.h"
+#include "inetworkmanager_interface.h"
#include "../common/bookmark.h"
class BrowserDbus : public QObject
@@ -72,6 +73,13 @@ public:
Q_INVOKABLE QString getFavicon(QString);
Q_INVOKABLE void activate();
Q_INVOKABLE void select();
+ Q_INVOKABLE void closeAlertDialog();
+ Q_INVOKABLE void closeConfirmDialog(conn::brw::DIALOG_RESULT);
+ Q_INVOKABLE void closePromptDialog(QString, conn::brw::DIALOG_RESULT);
+ Q_INVOKABLE QStringList getPrevEnteredValues(QString name, QString value, conn::brw::INPUT_ELEMENT_TYPE type);
+ Q_INVOKABLE void closeAuthenticationDialog(conn::brw::DIALOG_RESULT, const conn::brw::AuthenticationData&);
+ Q_INVOKABLE void closeSslErrorDialog(conn::brw::DIALOG_RESULT, bool);
+
QString title() { return m_title; }
void setTitle(QString title) { m_title = title; }
@@ -101,6 +109,15 @@ signals:
void onActionStateChanged(uint);
void onContentSizeChanged(uint, uint);
void onFaviconReceived();
+ void onConfirmDialog(QString);
+ void onPromptDialog(QString,QString);
+ void onAlertDialog(QString);
+ void onDialogCanceled(void);
+ void onSelect(const QString &, const conn::brw::SelectableOptionList &, bool);
+ void onAuthenticationDialog(const conn::brw::AuthenticationData&);
+ void onSslErrorDialog(const conn::brw::SslError&);
+ void onSslErrorDialogCancel(const conn::brw::SslError&);
+ void onAuthenticationDialogCancel(const conn::brw::AuthenticationData&);
public slots:
void pageloadingstarted();
@@ -112,13 +129,14 @@ public slots:
void InputTextReceived(QString a_strInputName, QString a_strDefaultInputValue, conn::brw::INPUT_ELEMENT_TYPE a_i32InputValueType, int a_s32MaxLength, int a_s32Max, int a_s32Min, int a_s32Step);
private:
- conn::brw::IBookmarkManager *bookmark = NULL;
- conn::brw::IUserInput *userinput = NULL;
- conn::brw::IWebPageWindow *webpagewindow = NULL;
- conn::brw::IWebPageWindow *actualtab = NULL;
- conn::brw::IUserInput *actualuserinput = NULL;
+ conn::brw::IBookmarkManager *bookmark;
+ conn::brw::IUserInput *userinput;
+ conn::brw::IWebPageWindow *webpagewindow;
+ conn::brw::IWebPageWindow *actualtab;
+ conn::brw::IUserInput *actualuserinput;
+ conn::brw::INetworkManager *networkmanager;
QList<conn::brw::OBJECT_HANDLE> handlelist;
- conn::brw::IBrowser *browser = NULL;
+ conn::brw::IBrowser *browser;
QString m_title;
QString m_url;
QList<Bookmark*> m_bookmarkList;
@@ -126,7 +144,7 @@ private:
int m_progress;
QString m_instanceId;
bool m_isconnected;
- QString *dbusservicename = NULL;
+ QString *dbusservicename;
void scrollpage(conn::brw::SCROLL_DIRECTION direction, conn::brw::SCROLL_TYPE type);
void registertypes();
QHash<conn::brw::OBJECT_HANDLE, conn::brw::IWebPageWindow *> webpagehash;
diff --git a/common/browserdefs.h b/common/browserdefs.h
index 9747173..f9c8e84 100644
--- a/common/browserdefs.h
+++ b/common/browserdefs.h
@@ -702,6 +702,143 @@ namespace conn {
return args;
//#]
}
+
+ /*!
+ * Authentication data used for Server and Proxy authentication.
+ */
+ //## type AuthenticationData
+ struct AuthenticationData
+ {
+ /*!
+ * Host name or Url for which the password is valid. In case of proxy authentication the customer receives "host:port" url, in case of the content authentication the url contans the resource URI.
+ */
+ QString strHost; //## attribute strHost
+ /*!
+ * User name
+ */
+ QString strUserName; //## attribute strUserName
+ /*!
+ * User password
+ */
+ QString strPassword; //## attribute strPassword
+ /*!
+ * Defines to store password into database.
+ */
+ bool bSave; //## attribute bSave
+
+ AuthenticationData()
+ :strHost("")
+ ,strUserName("")
+ ,strPassword("")
+ ,bSave(true)
+ {}
+ };
+ inline const QDBusArgument& operator>>(const QDBusArgument& args, AuthenticationData& ad) {
+ args.beginStructure();
+ args >> ad.strHost
+ >> ad.strUserName
+ >> ad.strPassword
+ >> ad.bSave;
+ args.endStructure();
+ return args;
+ }
+
+ inline QDBusArgument& operator<<(QDBusArgument& args, const AuthenticationData& ad) {
+ args.beginStructure();
+ args << ad.strHost
+ << ad.strUserName
+ << ad.strPassword
+ << ad.bSave;
+ args.endStructure();
+ return args;
+ }
+
+ /*!
+ * SslErrors
+ */
+ //## type SSL_ERROR
+ enum SSL_ERROR {
+ NoError,
+ UnableToGetIssuerCertificate,
+ UnableToDecryptCertificateSignature,
+ UnableToDecodeIssuerPublicKey,
+ CertificateSignatureFailed,
+ CertificateNotYetValid,
+ CertificateExpired,
+ InvalidNotBeforeField,
+ InvalidNotAfterField,
+ SelfSignedCertificate,
+ SelfSignedCertificateInChain,
+ UnableToGetLocalIssuerCertificate,
+ UnableToVerifyFirstCertificate,
+ CertificateRevoked,
+ InvalidCaCertificate,
+ PathLengthExceeded,
+ InvalidPurpose,
+ CertificateUntrusted,
+ CertificateRejected,
+ SubjectIssuerMismatch,
+ hostnamemismatch,
+ AuthorityIssuerSerialNumberMismatch,
+ NoPeerCertificate,
+ HostNameMismatch,
+ NoSslSupport,
+ CertificateBlacklisted,
+ UnspecifiedError = -1
+ };
+
+ inline const QDBusArgument& operator>>(const QDBusArgument& args, SSL_ERROR& e) {
+ args.beginStructure();
+ int temp =0;
+ args>>temp;
+ e = (SSL_ERROR)temp;
+ args.endStructure();
+ return args;
+ }
+
+ inline QDBusArgument& operator<<(QDBusArgument& args, const SSL_ERROR &e) {
+ args.beginStructure();
+ int param = e;
+ args << param;
+ args.endStructure();
+ return args;
+ }
+
+ /*!
+ * The SslError structure describes the error information happens during ssl connection.
+ */
+ //## type SslError
+ struct SslError {
+ /*!
+ * Error code. It could be HTTP error codes, or internal codes.
+ */
+ SSL_ERROR sslError; //## attribute sslError
+ /*!
+ * Url
+ */
+ QString strUrl; //## attribute strUrl
+ /*!
+ * Short text description of the error.
+ */
+ QString strErrorMessage; //## attribute strErrorMessage
+ };
+ inline const QDBusArgument& operator>>(const QDBusArgument& args, SslError& s) {
+ args.beginStructure();
+ args >> s.sslError
+ >> s.strUrl
+ >> s.strErrorMessage;
+ args.endStructure();
+ return args;
+ }
+
+ inline QDBusArgument& operator<<(QDBusArgument& args, const SslError& s) {
+ args.beginStructure();
+ args << s.sslError
+ << s.strUrl
+ << s.strErrorMessage;
+ args.endStructure();
+ return args;
+ }
}
}
@@ -719,9 +856,13 @@ Q_DECLARE_METATYPE(conn::brw::BrowserActions)
Q_DECLARE_METATYPE(conn::brw::OBJECT_HANDLE)
Q_DECLARE_METATYPE(conn::brw::ObjectHandleList)
Q_DECLARE_METATYPE(conn::brw::SelectableOption);
+Q_DECLARE_METATYPE(conn::brw::SelectableOptionList);
Q_DECLARE_METATYPE(conn::brw::CACHE_POLICY);
Q_DECLARE_METATYPE(conn::brw::ErrorItemList);
Q_DECLARE_METATYPE(conn::brw::ErrorItem);
Q_DECLARE_METATYPE(conn::brw::ERROR_SORT_TYPE);
+Q_DECLARE_METATYPE(conn::brw::AuthenticationData);
+Q_DECLARE_METATYPE(conn::brw::SslError);
+Q_DECLARE_METATYPE(conn::brw::SSL_ERROR);
#endif // BROWSERDEFS_H
diff --git a/common/errorloggerdbus.cpp b/common/errorloggerdbus.cpp
new file mode 100644
index 0000000..8b2f697
--- /dev/null
+++ b/common/errorloggerdbus.cpp
@@ -0,0 +1,101 @@
+/**
+ * Copyright (C) 2014, Pelagicore
+ *
+ * Author: Jonatan PĂ„lsson <jonatan.palsson@pelagicore.com>
+ *
+ * This file is part of the GENIVI project Browser Proof-Of-Concept
+ * For further information, see http://genivi.org/
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <QDBusMetaType>
+#include <QtQml>
+#include <QDBusReply>
+
+#include "errorloggerdbus.h"
+
+#include "../common/browserdefs.h"
+
+ErrorLoggerDbus::ErrorLoggerDbus(QObject *parent) :
+ QObject(parent), m_instanceId("1")
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ registertypes();
+}
+
+void ErrorLoggerDbus::registertypes() {
+ qDBusRegisterMetaType<conn::brw::ErrorItemList>();
+ qDBusRegisterMetaType<conn::brw::ErrorItem>();
+ qDBusRegisterMetaType<conn::brw::ERROR_SORT_TYPE>();
+}
+
+void ErrorLoggerDbus::connectdbussession(QString id) {
+ qDebug() << __PRETTY_FUNCTION__ << id;
+
+ m_instanceId = id;
+
+ QString *dbusservicename = new QString("genivi.poc.browser" + m_instanceId);
+
+ m_errorlogger = new conn::brw::IErrorLogger(*dbusservicename, "/Browser/IErrorLogger",
+ QDBusConnection::sessionBus(), this);
+ if(!m_errorlogger->isValid()) {
+ qDebug() << "failed create object /Browser/IErrorLogger";
+ }
+
+ connect(m_errorlogger, SIGNAL(onNewErrorItem(conn::brw::ErrorItem)),
+ this, SIGNAL(onNewErrorItem(conn::brw::ErrorItem)));
+ connect(m_errorlogger, SIGNAL(onErrorListChanged(void)),
+ this, SIGNAL(onErrorListChanged(void)));
+}
+
+uint ErrorLoggerDbus::getItemsCount(qlonglong start, qlonglong end) {
+ qDebug() << __PRETTY_FUNCTION__;
+ uint ret = 0;
+
+ if (!m_errorlogger){
+ qDebug() << "ErrorLogger not initialized, call connectdbussession first";
+ return ret;
+ }
+
+ QDBusReply<uint> reply = m_errorlogger->getItemsCount(start, end);
+
+ if(reply.isValid()) {
+ ret = reply.value();
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+ return ret;
+}
+conn::brw::ErrorItemList ErrorLoggerDbus::getItems(qlonglong timeFrom,
+ qlonglong timeTo,
+ conn::brw::ERROR_SORT_TYPE type,
+ uint startIndex,
+ uint itemsCount) {
+ qDebug() << __PRETTY_FUNCTION__;
+ conn::brw::ErrorItemList list;
+
+ if (!m_errorlogger){
+ qDebug() << "ErrorLogger not initialized, call connectdbussession first";
+ return list;
+ }
+
+ QDBusPendingReply<conn::brw::ERROR_IDS, conn::brw::ErrorItemList> reply =
+ m_errorlogger->getItems(timeFrom, timeTo, type, startIndex, itemsCount);
+
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret;
+ ret = reply.value();
+ list = reply.argumentAt<1>();
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+ return list;
+}
diff --git a/common/errorloggerdbus.h b/common/errorloggerdbus.h
new file mode 100644
index 0000000..0f80394
--- /dev/null
+++ b/common/errorloggerdbus.h
@@ -0,0 +1,37 @@
+#ifndef ERRRORLOGGERDBUS_H
+#define ERRRORLOGGERDBUS_H
+
+#include <QObject>
+#include "../browser/errorlogger.h"
+#include "browserdefs.h"
+#include "ierrorlogger_interface.h"
+
+class ErrorLoggerDbus : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit ErrorLoggerDbus(QObject *parent = 0);
+
+ Q_INVOKABLE uint getItemsCount(qlonglong, qlonglong);
+ Q_INVOKABLE conn::brw::ErrorItemList getItems(qlonglong timeFrom,
+ qlonglong timeTo,
+ conn::brw::ERROR_SORT_TYPE type,
+ uint startIndex,
+ uint itemsCount);
+
+ Q_INVOKABLE void connectdbussession(QString id);
+
+signals:
+ void onNewErrorItem(conn::brw::ErrorItem);
+ void onErrorListChanged();
+
+private:
+ QString m_instanceId;
+ void registertypes();
+ conn::brw::IErrorLogger *m_errorlogger;
+};
+
+
+
+#endif /* ERRRORLOGGERDBUS_H */