2013-08-09 13:04:52 +00:00
|
|
|
/*
|
|
|
|
* \brief A Qt Widget that can load a plugin application and show its Nitpicker view
|
|
|
|
* \author Christian Prochaska
|
|
|
|
* \date 2010-08-26
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
2013-08-09 13:04:52 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2013-08-09 13:04:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QPLUGINWIDGET_H
|
|
|
|
#define QPLUGINWIDGET_H
|
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
/* Genode includes */
|
|
|
|
#include <libc/component.h>
|
|
|
|
#include <loader_session/connection.h>
|
|
|
|
|
|
|
|
/* Qt includes */
|
2013-08-09 13:04:52 +00:00
|
|
|
#include <QtGui>
|
|
|
|
#include <QtNetwork>
|
|
|
|
|
|
|
|
#include <qnitpickerviewwidget/qnitpickerviewwidget.h>
|
|
|
|
|
|
|
|
enum Plugin_loading_state
|
|
|
|
{
|
|
|
|
LOADING,
|
|
|
|
LOADED,
|
|
|
|
NETWORK_ERROR,
|
|
|
|
INFLATE_ERROR,
|
2017-05-11 18:39:49 +00:00
|
|
|
CAP_QUOTA_EXCEEDED_ERROR,
|
|
|
|
RAM_QUOTA_EXCEEDED_ERROR,
|
2013-08-09 13:04:52 +00:00
|
|
|
ROM_CONNECTION_FAILED_EXCEPTION,
|
|
|
|
TIMEOUT_EXCEPTION
|
|
|
|
};
|
|
|
|
|
|
|
|
class QPluginWidget;
|
|
|
|
|
|
|
|
/* separate class, because meta object features are not supported in nested classes */
|
|
|
|
class PluginStarter : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
Libc::Env *_env;
|
|
|
|
QUrl _plugin_url;
|
|
|
|
QByteArray _args;
|
|
|
|
int _max_width;
|
|
|
|
int _max_height;
|
|
|
|
Nitpicker::View_capability _parent_view;
|
|
|
|
|
|
|
|
Loader::Connection *_pc;
|
|
|
|
enum Plugin_loading_state _plugin_loading_state;
|
|
|
|
QString _plugin_loading_error_string;
|
2013-08-09 13:04:52 +00:00
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
QNetworkAccessManager *_qnam;
|
|
|
|
QNetworkReply *_reply;
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
void _start_plugin(QString &file_name, QByteArray const &file_buf);
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void networkReplyFinished();
|
|
|
|
|
|
|
|
public:
|
2017-05-11 18:39:49 +00:00
|
|
|
PluginStarter(Libc::Env *env,
|
|
|
|
QUrl plugin_url, QString &args,
|
2014-06-11 14:22:44 +00:00
|
|
|
int max_width, int max_height,
|
|
|
|
Nitpicker::View_capability parent_view);
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
void run();
|
|
|
|
enum Plugin_loading_state plugin_loading_state() { return _plugin_loading_state; }
|
|
|
|
QString &plugin_loading_error_string() { return _plugin_loading_error_string; }
|
2014-06-11 14:22:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Requst size of the nitpicker view of the loaded subsystem
|
|
|
|
*/
|
|
|
|
Loader::Area view_size();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set geometry of the nitpicker view of the loaded subsystem
|
|
|
|
*/
|
|
|
|
void view_geometry(Loader::Rect rect, Loader::Point offset);
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void finished();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-11 14:22:44 +00:00
|
|
|
class QPluginWidget : public QEmbeddedViewWidget
|
2013-08-09 13:04:52 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
static Libc::Env *_env;
|
|
|
|
static QPluginWidget *_last;
|
2013-08-09 13:04:52 +00:00
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
enum Plugin_loading_state _plugin_loading_state;
|
|
|
|
QString _plugin_loading_error_string;
|
2014-06-04 19:15:28 +00:00
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
PluginStarter *_plugin_starter;
|
|
|
|
bool _plugin_starter_started;
|
2013-08-09 13:04:52 +00:00
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
QUrl _plugin_url;
|
|
|
|
QString _plugin_args;
|
2013-08-09 13:04:52 +00:00
|
|
|
|
2017-05-11 18:39:49 +00:00
|
|
|
int _max_width;
|
|
|
|
int _max_height;
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
public:
|
2017-05-11 18:39:49 +00:00
|
|
|
|
|
|
|
enum { PRESERVED_CAPS = 150 };
|
|
|
|
enum { PRESERVED_RAM_QUOTA = 5*1024*1024 };
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
protected:
|
2014-06-11 14:22:44 +00:00
|
|
|
virtual void paintEvent(QPaintEvent *);
|
|
|
|
virtual void showEvent(QShowEvent *);
|
|
|
|
virtual void hideEvent(QHideEvent *);
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void pluginStartFinished();
|
|
|
|
|
|
|
|
public:
|
2017-05-11 18:39:49 +00:00
|
|
|
QPluginWidget(QWidget *parent, QUrl plugin_url, QString &args,
|
|
|
|
int max_width = -1, int max_height = -1);
|
2013-08-09 13:04:52 +00:00
|
|
|
~QPluginWidget();
|
2017-05-11 18:39:49 +00:00
|
|
|
|
2017-05-23 12:39:08 +00:00
|
|
|
static void env(Libc::Env &env) { _env = &env; }
|
2013-08-09 13:04:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QPLUGINWIDGET_H
|