KParts
browserrun.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef kparts_browserrun_h
00020 #define kparts_browserrun_h
00021
00022 #include <krun.h>
00023 #include <kservice.h>
00024 #include <kparts/browserextension.h>
00025
00026 namespace KParts {
00027
00042 class KPARTS_EXPORT BrowserRun : public KRun
00043 {
00044 Q_OBJECT
00045 public:
00055 BrowserRun( const KURL& url, const KParts::URLArgs& args,
00056 KParts::ReadOnlyPart *part, QWidget *window,
00057 bool removeReferrer, bool trustedSource );
00058
00059
00071 BrowserRun( const KURL& url, const KParts::URLArgs& args,
00072 KParts::ReadOnlyPart *part, QWidget *window,
00073 bool removeReferrer, bool trustedSource, bool hideErrorDialog );
00074
00075 virtual ~BrowserRun();
00076
00077
00078
00079
00083 KURL url() const { return m_strURL; }
00084
00088 bool hideErrorDialog() const;
00089
00093 QString suggestedFilename() const { return m_suggestedFilename; }
00094
00099 QString contentDisposition() const;
00100
00101 bool serverSuggestsSave() const { return contentDisposition() == QString::fromLatin1("attachment"); }
00102
00103 enum AskSaveResult { Save, Open, Cancel };
00112 static AskSaveResult askSave( const KURL & url, KService::Ptr offer, const QString& mimeType, const QString & suggestedFilename = QString::null );
00113
00114 enum AskEmbedOrSaveFlags { InlineDisposition = 0, AttachmentDisposition = 1 };
00124 static AskSaveResult askEmbedOrSave( const KURL & url, const QString& mimeType, const QString & suggestedFilename = QString::null, int flags = 0 );
00125
00126
00127 virtual void save( const KURL & url, const QString & suggestedFilename );
00128
00129
00130 static void simpleSave( const KURL & url, const QString & suggestedFilename,
00131 QWidget* window );
00132
00134 static void simpleSave( const KURL & url, const QString & suggestedFilename );
00135
00136 static bool allowExecution( const QString &serviceType, const KURL &url );
00137
00139 static bool isExecutable( const QString &serviceType );
00140 static bool isTextExecutable( const QString &serviceType );
00141
00142 protected:
00146 virtual void scanFile();
00150 virtual void init();
00158 virtual void handleError( KIO::Job * job );
00159
00164 enum NonEmbeddableResult { Handled, NotHandled, Delayed };
00165
00169 NonEmbeddableResult handleNonEmbeddable( const QString& mimeType );
00170
00171 protected slots:
00172 void slotBrowserScanFinished(KIO::Job *job);
00173 void slotBrowserMimetype(KIO::Job *job, const QString &type);
00174 void slotCopyToTempFileResult(KIO::Job *job);
00175 virtual void slotStatResult( KIO::Job *job );
00176
00177 protected:
00178 KParts::URLArgs m_args;
00179 KParts::ReadOnlyPart *m_part;
00180 QGuardedPtr<QWidget> m_window;
00181
00182
00183 QString m_suggestedFilename;
00184 QString m_sMimeType;
00185 bool m_bRemoveReferrer;
00186 bool m_bTrustedSource;
00187 private:
00188 void redirectToError( int error, const QString& errorText );
00189 class BrowserRunPrivate;
00190 BrowserRunPrivate* d;
00191
00192 };
00193 }
00194 #endif