BrowserRun Class Reference
from PyKDE4.kparts import *
Inherits: KRun → QObject
Namespace: KParts
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> 
| 
 Enumerations | 
| AskEmbedOrSaveFlags | { InlineDisposition, AttachmentDisposition } | 
| AskSaveResult | { Save, Open, Cancel } | 
| NonEmbeddableResult | { Handled, NotHandled, Delayed } | 
| 
 Methods | 
|  | __init__ (self, KUrl url, KParts.OpenUrlArguments args, KParts.BrowserArguments browserArgs, KParts.ReadOnlyPart part, QWidget window, bool removeReferrer, bool trustedSource, bool hideErrorDialog=0) | 
| KParts.OpenUrlArguments | arguments (self) | 
| KParts.BrowserArguments | browserArguments (self) | 
| QString | contentDisposition (self) | 
|  | handleError (self, KJob job) | 
| KParts.BrowserRun.NonEmbeddableResult | handleNonEmbeddable (self, QString mimeType) | 
| bool | hideErrorDialog (self) | 
|  | init (self) | 
| KParts.ReadOnlyPart | part (self) | 
|  | save (self, KUrl url, QString suggestedFileName) | 
|  | scanFile (self) | 
| bool | serverSuggestsSave (self) | 
|  | slotBrowserMimetype (self, KIO.Job job, QString type) | 
|  | slotBrowserScanFinished (self, KJob job) | 
|  | slotCopyToTempFileResult (self, KJob job) | 
|  | slotStatResult (self, KJob job) | 
| KUrl | url (self) | 
| 
 Static Methods | 
| bool | allowExecution (QString mimeType, KUrl url) | 
| KParts.BrowserRun.AskSaveResult | askEmbedOrSave (KUrl url, QString mimeType, QString suggestedFileName=QString(), int flags=0) | 
| KParts.BrowserRun.AskSaveResult | askSave (KUrl url, KService.Ptr offer, QString mimeType, QString suggestedFileName=QString()) | 
| bool | isTextExecutable (QString mimeType) | 
|  | simpleSave (KUrl url, QString suggestedFileName, QWidget window=0) | 
Method Documentation
- Parameters:
- 
|  | url | the URL we're probing |  |  | args | URL args - includes reload, metaData, etc. |  |  | browserArgs | browser-related args - includes data for a HTTP POST, etc. |  |  | part | the part going to open this URL - can be 0 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. |  |  | hideErrorDialog | if true, no dialog will be shown in case of errors. |  
 
 
| KParts.BrowserRun.AskSaveResult askEmbedOrSave | ( | KUrl | url, | 
|  |  | QString | mimeType, | 
|  |  | QString | suggestedFileName=QString(), | 
|  |  | int | flags=0 | 
|  | ) |  |  |  | 
 
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.
 
| KParts.BrowserRun.AskSaveResult askSave | ( | KUrl | url, | 
|  |  | KService.Ptr | offer, | 
|  |  | QString | mimeType, | 
|  |  | QString | suggestedFileName=QString() | 
|  | ) |  |  |  | 
 
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 file name suggested by the server |  
 
 
- Returns:
-  Save, Open or Cancel.
 
| QString contentDisposition | ( |  | self ) |  | 
 
- Returns:
-  Suggested disposition by the server (e.g. HTTP content-disposition)
 
| handleError | ( | self, |  | 
|  |  | KJob | job | 
|  | ) |  |  |  | 
 
Called when an error happens.
NOTE: job could be 0, 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.
 
| KParts.BrowserRun.NonEmbeddableResult handleNonEmbeddable | ( | self, |  | 
|  |  | QString | mimeType | 
|  | ) |  |  |  | 
 
Helper for foundMimeType: call this if the mimetype couldn't be embedded
 
| bool hideErrorDialog | ( |  | self ) |  | 
 
 
| bool isTextExecutable | ( | QString | mimeType | 
|  | ) |  |  |  | 
 
 
| bool serverSuggestsSave | ( |  | self ) |  | 
 
 
| slotBrowserScanFinished | ( | self, |  | 
|  |  | KJob | job | 
|  | ) |  |  |  | 
 
 
| slotCopyToTempFileResult | ( | self, |  | 
|  |  | KJob | job | 
|  | ) |  |  |  | 
 
 
| slotStatResult | ( | self, |  | 
|  |  | KJob | job | 
|  | ) |  |  |  | 
 
 
Enumeration Documentation
- Enumerator: 
- 
| InlineDisposition = 0 |  |  | AttachmentDisposition = 1 |  |  
 
 
NotHandled means that foundMimeType should call KRun.foundMimeType,
i.e. launch an external app.
- Enumerator: 
- 
| Handled |  |  | NotHandled |  |  | Delayed |  |