• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KParts

  • KParts
  • BrowserRun
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Slots | Protected Member Functions | List of all members
KParts::BrowserRun Class Reference

#include <browserrun.h>

Inheritance diagram for KParts::BrowserRun:
Inheritance graph
[legend]

Public Types

enum  AskEmbedOrSaveFlags { InlineDisposition = 0, AttachmentDisposition = 1 }
 
enum  AskSaveResult { Save, Open, Cancel }
 

Public Member Functions

 BrowserRun (const KUrl &url, const KParts::OpenUrlArguments &args, const KParts::BrowserArguments &browserArgs, KParts::ReadOnlyPart *part, QWidget *window, bool removeReferrer, bool trustedSource, bool hideErrorDialog=false)
 
virtual ~BrowserRun ()
 
KParts::OpenUrlArguments & arguments ()
 
KParts::BrowserArguments & browserArguments ()
 
QString contentDisposition () const
 
bool hideErrorDialog () const
 
KParts::ReadOnlyPart * part () const
 
virtual void save (const KUrl &url, const QString &suggestedFileName)
 
bool serverSuggestsSave () const
 
KUrl url () const
 
- Public Member Functions inherited from KRun
 KRun (const KUrl &url, QWidget *window, mode_t mode=0, bool isLocalFile=false, bool showProgressInfo=true, const QByteArray &asn=QByteArray())
 
virtual ~KRun ()
 
void abort ()
 
bool autoDelete () const
 
bool hasError () const
 
bool hasFinished () const
 
void setAutoDelete (bool b)
 
void setEnableExternalBrowser (bool b)
 
void setPreferredService (const QString &desktopEntryName)
 
void setRunExecutables (bool b)
 
void setSuggestedFileName (const QString &fileName)
 
QString suggestedFileName () const
 
QWidget * window () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Static Public Member Functions

static bool allowExecution (const QString &mimeType, const KUrl &url)
 
static AskSaveResult askEmbedOrSave (const KUrl &url, const QString &mimeType, const QString &suggestedFileName=QString(), int flags=0)
 
static AskSaveResult askSave (const KUrl &url, KService::Ptr offer, const QString &mimeType, const QString &suggestedFileName=QString())
 
static bool isTextExecutable (const QString &mimeType)
 
static KUrl makeErrorUrl (int error, const QString &errorText, const QString &initialUrl)
 
static void saveUrl (const KUrl &url, const QString &suggestedFileName, QWidget *window, const KParts::OpenUrlArguments &args)
 
static void saveUrlUsingKIO (const KUrl &srcUrl, const KUrl &destUrl, QWidget *window, const QMap< QString, QString > &metaData)
 
static void simpleSave (const KUrl &url, const QString &suggestedFileName, QWidget *window=0)
 
- Static Public Member Functions inherited from KRun
static QString binaryName (const QString &execLine, bool removePath)
 
static bool checkStartupNotify (const QString &binName, const KService *service, bool *silent_arg, QByteArray *wmclass_arg)
 
static bool displayOpenWithDialog (const KUrl::List &lst, QWidget *window, bool tempFiles=false, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
 
static bool isExecutable (const QString &serviceType)
 
static bool isExecutableFile (const KUrl &url, const QString &mimetype)
 
static QStringList processDesktopExec (const KService &_service, const KUrl::List &_urls, bool tempFiles=false, const QString &suggestedFileName=QString())
 
static bool run (const QString &exec, const KUrl::List &urls, QWidget *window, const QString &name=QString(), const QString &icon=QString(), const QByteArray &asn=QByteArray())
 
static bool run (const KService &service, const KUrl::List &urls, QWidget *window, bool tempFiles=false, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
 
static bool runCommand (const QString &cmd, QWidget *window)
 
static bool runCommand (const QString &cmd, const QString &execName, const QString &icon, QWidget *window, const QByteArray &asn=QByteArray())
 
static bool runCommand (const QString &cmd, QWidget *window, const QString &workingDirectory)
 
static bool runCommand (const QString &cmd, const QString &execName, const QString &icon, QWidget *window, const QByteArray &asn, const QString &workingDirectory)
 
static bool runUrl (const KUrl &url, const QString &mimetype, QWidget *window, bool tempFile=false, bool runExecutables=true, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
 
static void shellQuote (QString &str)
 
- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Protected Types

enum  NonEmbeddableResult { Handled, NotHandled, Delayed }
 

Protected Slots

void slotBrowserMimetype (KIO::Job *job, const QString &type)
 
void slotBrowserScanFinished (KJob *job)
 
void slotCopyToTempFileResult (KJob *job)
 
virtual void slotStatResult (KJob *job)
 
- Protected Slots inherited from KRun
void mimeTypeDetermined (const QString &mimeType)
 
void slotScanFinished (KJob *)
 
void slotScanMimeType (KIO::Job *, const QString &type)
 
virtual void slotStatResult (KJob *)
 
void slotTimeout ()
 

Protected Member Functions

virtual void handleError (KJob *job)
 
NonEmbeddableResult handleNonEmbeddable (const QString &mimeType)
 
NonEmbeddableResult handleNonEmbeddable (const QString &mimeType, KService::Ptr *pSelectedService)
 
virtual void init ()
 
virtual void scanFile ()
 
- Protected Member Functions inherited from KRun
bool doScanFile () const
 
virtual void foundMimeType (const QString &type)
 
bool initializeNextAction () const
 
bool isDirectory () const
 
bool isLocalFile () const
 
KIO::Job * job ()
 
virtual void killJob ()
 
mode_t mode () const
 
bool progressInfo () const
 
void setDoScanFile (bool scanFile)
 
void setError (bool error)
 
void setFinished (bool finished)
 
void setInitializeNextAction (bool initialize)
 
void setIsDirecory (bool isDirectory)
 
void setIsLocalFile (bool isLocalFile)
 
void setJob (KIO::Job *job)
 
void setMode (mode_t mode)
 
void setProgressInfo (bool progressInfo)
 
void setUrl (const KUrl &url)
 
QTimer & timer ()
 
KUrl url () const
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Signals inherited from KRun
void error ()
 
void finished ()
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

This class extends KRun to provide additional functionality for browsers:

  • "save or open" dialog boxes
  • "save" functionality
  • support for HTTP POST (including saving the result to a temp file if opening a separate application)
  • warning before launching executables off the web
  • custom error handling (i.e. treating errors as HTML pages)
  • generation of SSL metadata depending on the previous URL shown by the part
    Author
    David Faure faure.nosp@m.@kde.nosp@m..org

Definition at line 39 of file browserrun.h.

Member Enumeration Documentation

enum KParts::BrowserRun::AskEmbedOrSaveFlags
Enumerator
InlineDisposition 
AttachmentDisposition 

Definition at line 98 of file browserrun.h.

enum KParts::BrowserRun::AskSaveResult
Enumerator
Save 
Open 
Cancel 

Definition at line 80 of file browserrun.h.

enum KParts::BrowserRun::NonEmbeddableResult
protected

NotHandled means that foundMimeType should call KRun::foundMimeType, i.e.

launch an external app.

Enumerator
Handled 
NotHandled 
Delayed 

Definition at line 176 of file browserrun.h.

Constructor & Destructor Documentation

BrowserRun::BrowserRun ( const KUrl &  url,
const KParts::OpenUrlArguments &  args,
const KParts::BrowserArguments &  browserArgs,
KParts::ReadOnlyPart *  part,
QWidget *  window,
bool  removeReferrer,
bool  trustedSource,
bool  hideErrorDialog = false 
)
Parameters
urlthe URL we're probing
argsURL args - includes reload, metaData, etc.
browserArgsbrowser-related args - includes data for a HTTP POST, etc.
partthe part going to open this URL - can be 0 if not created yet
windowthe mainwindow - passed to KIO::Job::setWindow()
removeReferrerif true, the "referrer" metadata from args isn't passed on
trustedSourceif false, a warning will be shown before launching an executable. Always pass false for trustedSource, except for local directory views.
hideErrorDialogif true, no dialog will be shown in case of errors.

Definition at line 57 of file browserrun.cpp.

BrowserRun::~BrowserRun ( )
virtual

Definition at line 73 of file browserrun.cpp.

Member Function Documentation

bool BrowserRun::allowExecution ( const QString &  mimeType,
const KUrl &  url 
)
static

Definition at line 344 of file browserrun.cpp.

KParts::OpenUrlArguments & KParts::BrowserRun::arguments ( )

Definition at line 595 of file browserrun.cpp.

BrowserRun::AskSaveResult BrowserRun::askEmbedOrSave ( const KUrl &  url,
const QString &  mimeType,
const QString &  suggestedFileName = QString(),
int  flags = 0 
)
static

Similar to askSave but for the case where the current application is able to embed the url itself (instead of passing it to another app).

Parameters
urlthe URL in question
mimeTypethe mimetype of the URL
suggestedFileNameoptional filename suggested by the server
flagsset to AttachmentDisposition if suggested by the server
Returns
Save, Open or Cancel.
Deprecated:
use BrowserOpenOrSaveQuestion
BrowserOpenOrSaveQuestion dlg(parent, url, mimeType, suggestedFileName);
const BrowserOpenOrSaveQuestion::Result res = dlg.askEmbedOrSave(flags);
// Important: returns Embed now, not Open!

Definition at line 373 of file browserrun.cpp.

BrowserRun::AskSaveResult BrowserRun::askSave ( const KUrl &  url,
KService::Ptr  offer,
const QString &  mimeType,
const QString &  suggestedFileName = QString() 
)
static

Ask the user whether to save or open a url in another application.

Parameters
urlthe URL in question
offerthe application that will be used to open the URL
mimeTypethe mimetype of the URL
suggestedFileNameoptional file name suggested by the server
Returns
Save, Open or Cancel.
Deprecated:
use BrowserOpenOrSaveQuestion
BrowserOpenOrSaveQuestion dlg(parent, url, mimeType, suggestedFileName);
const BrowserOpenOrSaveQuestion::Result res = dlg.askOpenOrSave();

Definition at line 359 of file browserrun.cpp.

KParts::BrowserArguments & KParts::BrowserRun::browserArguments ( )

Definition at line 600 of file browserrun.cpp.

QString BrowserRun::contentDisposition ( ) const
Returns
Suggested disposition by the server (e.g. HTTP content-disposition)

Definition at line 583 of file browserrun.cpp.

void BrowserRun::handleError ( KJob *  job)
protectedvirtual

Called when an error happens.

NOTE: job could be 0L, if you passed hideErrorDialog=true. The default implementation shows a message box, but only when job != 0 .... It is strongly recommended to reimplement this method if you passed hideErrorDialog=true.

Definition at line 491 of file browserrun.cpp.

BrowserRun::NonEmbeddableResult BrowserRun::handleNonEmbeddable ( const QString &  mimeType)
protected

Helper for foundMimeType: call this if the mimetype couldn't be embedded.

Definition at line 265 of file browserrun.cpp.

BrowserRun::NonEmbeddableResult BrowserRun::handleNonEmbeddable ( const QString &  mimeType,
KService::Ptr *  pSelectedService 
)
protected

Helper for foundMimeType: call this if the mimetype couldn't be embedded.

Parameters
mimeTypethe mimetype found for the URL
pSelectedServiceOutput variable: pointer to a KService::Ptr, which will be set to the service selected in the BrowserOpenOrSaveQuestion dialog, if any.

How to handle this properly: if pSelectedService is non-zero, then the dialog will show additional "open with" buttons. In your code, you should write:

if (selectedService) {
KRun::setPreferredService(selectedService->desktopEntryName()); // not necessary since 4.9.3
KRun::foundMimeType(mimeType);
} else { // the user requested an open-with dialog
KRun::displayOpenWithDialog(url(), m_window, false, suggestedFileName());
setFinished(true);
}
Since
4.5

Definition at line 270 of file browserrun.cpp.

bool BrowserRun::hideErrorDialog ( ) const

Definition at line 578 of file browserrun.cpp.

void BrowserRun::init ( )
protectedvirtual

Reimplemented from KRun.

Reimplemented from KRun.

Definition at line 88 of file browserrun.cpp.

bool BrowserRun::isTextExecutable ( const QString &  mimeType)
static

Definition at line 572 of file browserrun.cpp.

KUrl BrowserRun::makeErrorUrl ( int  error,
const QString &  errorText,
const QString &  initialUrl 
)
static

KDE webbrowsing kparts support error urls to display errors in-line in the browser component.

This helper method creates the error URL from its parameters.

Parameters
errorthe KIO error code (or KIO::ERR_SLAVE_DEFINED if not from KIO)
errorTextthe text of the error message
initialUrlthe URL that we were trying to open (as a string, so that this can support invalid URLs as well)
Since
4.6

Definition at line 520 of file browserrun.cpp.

KParts::ReadOnlyPart * BrowserRun::part ( ) const

Definition at line 78 of file browserrun.cpp.

void BrowserRun::save ( const KUrl &  url,
const QString &  suggestedFileName 
)
virtual

Definition at line 385 of file browserrun.cpp.

void KParts::BrowserRun::saveUrl ( const KUrl &  url,
const QString &  suggestedFileName,
QWidget *  window,
const KParts::OpenUrlArguments &  args 
)
static

If kget integration is enabled, passes the url to kget.

Otherwise, asks the user for a destination url, and calls saveUrlUsingKIO.

Since
4.4

Definition at line 397 of file browserrun.cpp.

void BrowserRun::saveUrlUsingKIO ( const KUrl &  srcUrl,
const KUrl &  destUrl,
QWidget *  window,
const QMap< QString, QString > &  metaData 
)
static

Starts the KIO file copy job to download srcUrl into destUrl.

Since
4.4

Definition at line 465 of file browserrun.cpp.

void BrowserRun::scanFile ( )
protectedvirtual

Reimplemented from KRun.

Reimplemented from KRun.

Definition at line 116 of file browserrun.cpp.

bool BrowserRun::serverSuggestsSave ( ) const
Returns
Wheter the returned disposition suggests saving or opening inline

Definition at line 588 of file browserrun.cpp.

void BrowserRun::simpleSave ( const KUrl &  url,
const QString &  suggestedFileName,
QWidget *  window = 0 
)
static

Definition at line 391 of file browserrun.cpp.

void BrowserRun::slotBrowserMimetype ( KIO::Job *  job,
const QString &  type 
)
protectedslot

Definition at line 214 of file browserrun.cpp.

void BrowserRun::slotBrowserScanFinished ( KJob *  job)
protectedslot

Definition at line 182 of file browserrun.cpp.

void BrowserRun::slotCopyToTempFileResult ( KJob *  job)
protectedslot

Definition at line 560 of file browserrun.cpp.

void BrowserRun::slotStatResult ( KJob *  job)
protectedvirtualslot

Definition at line 482 of file browserrun.cpp.

KUrl BrowserRun::url ( ) const

Definition at line 83 of file browserrun.cpp.


The documentation for this class was generated from the following files:
  • browserrun.h
  • browserrun.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:25:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KParts

Skip menu "KParts"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal