kparts Library API Documentation

KParts::BrowserRun Class Reference

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. More...

#include <browserrun.h>

Inheritance diagram for KParts::BrowserRun:

KRun QObject List of all members.

Public Methods

 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)

Static Public Methods

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

Protected Types

enum  NonEmbeddableResult

Protected Slots

void slotCopyToTempFileResult (KIO::Job *job)

Protected Methods

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

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.

Author:
David Faure <faure@kde.org>

Definition at line 39 of file browserrun.h.


Member Enumeration Documentation

enum KParts::BrowserRun::NonEmbeddableResult [protected]
 

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

launch an external app.

Definition at line 141 of file browserrun.h.


Constructor & Destructor Documentation

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.

Definition at line 41 of file browserrun.cpp.

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.

Definition at line 53 of file browserrun.cpp.


Member Function Documentation

BrowserRun::AskSaveResult 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.

Definition at line 295 of file browserrun.cpp.

References QString::fromLatin1(), and KMessageBox::questionYesNoCancel().

Referenced by handleNonEmbeddable().

BrowserRun::AskSaveResult 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  reserved for later use
Returns:
Save, Open or Cancel.

Definition at line 312 of file browserrun.cpp.

References QString::fromLatin1(), KMimeType::mimeType(), KMimeType::Ptr, KMessageBox::questionYesNoCancel(), and QString::startsWith().

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

BIC: Combine with the above function for KDE 4.0.

Definition at line 348 of file browserrun.cpp.

bool BrowserRun::isExecutable const QString   serviceType [static]
 

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

Reimplemented from KRun.

Definition at line 482 of file browserrun.cpp.

References KRun::isExecutable().

void BrowserRun::scanFile   [protected, virtual]
 

Reimplemented from KRun.

Definition at line 97 of file browserrun.cpp.

References QObject::connect(), QMap< QString, QString >::contains(), KParts::URLArgs::contentType(), KParts::URLArgs::doPost(), KMimeType::findByURL(), KRun::foundMimeType(), KIO::get(), KIO::http_post(), QMap< QString, QString >::insert(), QString::lower(), KParts::URLArgs::metaData(), KIO::mimetype(), KParts::URLArgs::postData, KURL::protocol(), KMimeType::Ptr, KParts::URLArgs::reload, QMap< QString, QString >::remove(), and KParts::ReadOnlyPart::url().

void BrowserRun::init   [protected, virtual]
 

Reimplemented from KRun.

Definition at line 69 of file browserrun.cpp.

References QFile::encodeName().

void 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.

Definition at line 419 of file browserrun.cpp.

References KIO::Job::error(), and KIO::Job::errorText().

BrowserRun::NonEmbeddableResult BrowserRun::handleNonEmbeddable const QString   mimeType [protected]
 

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

Definition at line 199 of file browserrun.cpp.

References askSave(), QObject::connect(), KParts::URLArgs::doPost(), KIO::file_copy(), QString::findRev(), QString::fromLatin1(), QString::isEmpty(), QString::mid(), KTempFile::name(), KServiceTypeProfile::preferredService(), KIO::SimpleJob::removeOnHold(), KURL::setPath(), KIO::Job::setWindow(), and slotCopyToTempFileResult().

void BrowserRun::slotCopyToTempFileResult KIO::Job   job [protected, slot]
 

To display this error in KHTMLPart instead of inside a dialog box, we tell konq that the mimetype is text/html, and we redirect to an error:/ URL that sends the info to khtml.

The format of the error:/ URL is error:/?query::url, where two variables are passed in the query: error = int kio error code, errText = QString error text from kio The sub-url is the URL that we were trying to open.

Definition at line 463 of file browserrun.cpp.

References KIO::Job::error(), KRun::runURL(), and KIO::Job::showErrorDialog().

Referenced by handleNonEmbeddable().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kparts Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 22 14:24:39 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003