KParts::BrowserRun Class Reference

#include <browserrun.h>

List of all members.


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@kde.org>

Definition at line 42 of file browserrun.h.


Public Types

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

Public Member Functions

 BrowserRun (const KURL &url, const KParts::URLArgs &args, KParts::ReadOnlyPart *part, QWidget *window, bool removeReferrer, bool trustedSource)
 BrowserRun (const KURL &url, const KParts::URLArgs &args, KParts::ReadOnlyPart *part, QWidget *window, bool removeReferrer, bool trustedSource, bool hideErrorDialog)
KURL url () const
bool hideErrorDialog () const
QString suggestedFilename () const
QString contentDisposition () const
bool serverSuggestsSave () const
virtual void save (const KURL &url, const QString &suggestedFilename)

Static Public Member Functions

static AskSaveResult askSave (const KURL &url, KService::Ptr offer, const QString &mimeType, const QString &suggestedFilename=QString::null)
static AskSaveResult askEmbedOrSave (const KURL &url, const QString &mimeType, const QString &suggestedFilename=QString::null, int flags=0)
static void simpleSave (const KURL &url, const QString &suggestedFilename, QWidget *window)
static void simpleSave (const KURL &url, const QString &suggestedFilename)
static bool allowExecution (const QString &serviceType, const KURL &url)
static bool isExecutable (const QString &serviceType)
static bool isTextExecutable (const QString &serviceType)

Protected Types

 Handled
 NotHandled
 Delayed
enum  NonEmbeddableResult { Handled, NotHandled, Delayed }

Protected Slots

void slotBrowserScanFinished (KIO::Job *job)
void slotBrowserMimetype (KIO::Job *job, const QString &type)
void slotCopyToTempFileResult (KIO::Job *job)
virtual void slotStatResult (KIO::Job *job)

Protected Member Functions

virtual void scanFile ()
virtual void init ()
virtual void handleError (KIO::Job *job)
NonEmbeddableResult handleNonEmbeddable (const QString &mimeType)

Protected Attributes

KParts::URLArgs m_args
KParts::ReadOnlyPartm_part
QGuardedPtr< QWidgetm_window
QString m_suggestedFilename
QString m_sMimeType
bool m_bRemoveReferrer
bool m_bTrustedSource

Member Enumeration Documentation

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

launch an external app.

Definition at line 163 of file browserrun.h.


Constructor & Destructor Documentation

KParts::BrowserRun::BrowserRun ( const KURL url,
const KParts::URLArgs args,
KParts::ReadOnlyPart part,
QWidget window,
bool  removeReferrer,
bool  trustedSource 
)

Parameters:
url the URL we're probing
args URL args - includes data for a HTTP POST, etc.
part the part going to open this URL - can be 0L if not created yet
window the mainwindow - passed to KIO::Job::setWindow()
removeReferrer if true, the "referrer" metadata from args isn't passed on
trustedSource if false, a warning will be shown before launching an executable Always pass false for trustedSource, except for local directory views.

KParts::BrowserRun::BrowserRun ( const KURL url,
const KParts::URLArgs args,
KParts::ReadOnlyPart part,
QWidget window,
bool  removeReferrer,
bool  trustedSource,
bool  hideErrorDialog 
)

Parameters:
url the URL we're probing
args URL args - includes data for a HTTP POST, etc.
part the part going to open this URL - can be 0L if not created yet
window the mainwindow - passed to KIO::Job::setWindow()
removeReferrer if true, the "referrer" metadata from args isn't passed on
trustedSource if false, a warning will be shown before launching an executable
hideErrorDialog if true, no dialog will be shown in case of errors. Always pass false for trustedSource, except for local directory views.


Member Function Documentation

static AskSaveResult KParts::BrowserRun::askEmbedOrSave ( const KURL url,
const QString mimeType,
const QString suggestedFilename = QString::null,
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:
url the URL in question
mimeType the mimetype of the URL
suggestedFilename optional filename suggested by the server
flags set to AttachmentDisposition if suggested by the server
Returns:
Save, Open or Cancel.

static AskSaveResult KParts::BrowserRun::askSave ( const KURL url,
KService::Ptr  offer,
const QString mimeType,
const QString suggestedFilename = QString::null 
) [static]

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

Parameters:
url the URL in question
offer the application that will be used to open the URL
mimeType the mimetype of the URL
suggestedFilename optional filename suggested by the server
Returns:
Save, Open or Cancel.

QString KParts::BrowserRun::contentDisposition (  )  const

Returns:
Suggested disposition by the server (e.g. HTTP content-disposition)
Since:
3.5.2

virtual void KParts::BrowserRun::handleError ( KIO::Job *  job  )  [protected, virtual]

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.

NonEmbeddableResult KParts::BrowserRun::handleNonEmbeddable ( const QString mimeType  )  [protected]

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

bool KParts::BrowserRun::hideErrorDialog (  )  const

Returns:
true if no dialog will be shown in case of errors

virtual void KParts::BrowserRun::init (  )  [protected, virtual]

Reimplemented from KRun.

static bool KParts::BrowserRun::isExecutable ( const QString serviceType  )  [static]

BIC: Obsoleted by KRun::isExecutable( const QString &serviceType );.

virtual void KParts::BrowserRun::scanFile (  )  [protected, virtual]

Reimplemented from KRun.

static void KParts::BrowserRun::simpleSave ( const KURL url,
const QString suggestedFilename 
) [static]

BIC: Combine with the above function for KDE 4.0.

QString KParts::BrowserRun::suggestedFilename (  )  const [inline]

Returns:
Suggested filename given by the server (e.g. HTTP content-disposition filename)

Definition at line 92 of file browserrun.h.

KURL KParts::BrowserRun::url (  )  const [inline]

Returns:
the URL we're probing

Definition at line 82 of file browserrun.h.


The documentation for this class was generated from the following file:
KDE Home | KDE Accessibility Home | Description of Access Keys