|
|
|
/*! @file
|
|
|
|
|
|
|
|
@id $Id$
|
|
|
|
*/
|
|
|
|
// 1 2 3 4 5 6 7 8
|
|
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
|
|
|
|
|
|
#ifndef __PLUGINFACTORY_HXX__
|
|
|
|
#define __PLUGINFACTORY_HXX__
|
|
|
|
|
|
|
|
#include <qbrowserlib/log.hxx>
|
|
|
|
#include <QtWebKit/QWebPluginFactory>
|
|
|
|
#include <qbrowserlib/saveorrun.hxx>
|
|
|
|
|
|
|
|
//! @addtogroup qbrowserlib
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
namespace qbrowserlib {
|
|
|
|
|
|
|
|
//! Handle PDF Documents
|
|
|
|
/*! */
|
|
|
|
class PluginFactory: public QWebPluginFactory {
|
|
|
|
Q_OBJECT;
|
|
|
|
Q_SIGNALS:
|
|
|
|
void done();
|
|
|
|
public:
|
|
|
|
PluginFactory(QNetworkAccessManager* net, QObject* p=0):
|
|
|
|
QWebPluginFactory(p), _net(net) {
|
|
|
|
TRC;
|
|
|
|
// Plugin plugin;
|
|
|
|
// plugin.name = "Show PDF-Document";
|
|
|
|
// plugin.description = "Plugin for PDF documents";
|
|
|
|
// MimeType mime;
|
|
|
|
// mime.fileExtensions<<"pdf";
|
|
|
|
// mime.name = "application/pdf";
|
|
|
|
// mime.description = "PDF-Document";
|
|
|
|
// plugin.mimeTypes<<mime;
|
|
|
|
// _plugins.push_back(plugin);
|
|
|
|
}
|
|
|
|
virtual QObject* create(const QString& mimeType, const QUrl& url,
|
|
|
|
const QStringList& argumentNames,
|
|
|
|
const QStringList& argumentValues ) const {
|
|
|
|
TRC; LOG<<"mimeType:"<<mimeType
|
|
|
|
<<"url:"<<url
|
|
|
|
<<"argumentNames:"<<argumentNames.join(", ")
|
|
|
|
<<"argumentValues:"<<argumentValues.join(", ");
|
|
|
|
// if (mimeType=="application/pdf") {
|
|
|
|
// return new SaveOrRunPlugin(url, mimeType);
|
|
|
|
// }
|
|
|
|
QNetworkRequest req(url);
|
|
|
|
QNetworkReply* reply(_net->get(QNetworkRequest(url)));
|
|
|
|
SaveOrRunPlugin* p(new SaveOrRunPlugin(reply, url, mimeType));
|
|
|
|
assert(connect(p, SIGNAL(accept()), SIGNAL(done())));
|
|
|
|
if (p->handlePreconfigured()) {
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
delete p; p=0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
virtual QList<Plugin> plugins() const {
|
|
|
|
TRC;
|
|
|
|
return _plugins;
|
|
|
|
}
|
|
|
|
virtual void refreshPlugins() {
|
|
|
|
TRC;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
QList<Plugin> _plugins;
|
|
|
|
QNetworkAccessManager* _net;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//! @}
|
|
|
|
#endif
|