browserrun.h00001
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
00070 BrowserRun( const KURL& url, const KParts::URLArgs& args,
00071 KParts::ReadOnlyPart *part, QWidget *window,
00072 bool removeReferrer, bool trustedSource, bool hideErrorDialog );
00073
00074 virtual ~BrowserRun();
00075
00076
00077
00078
00082 KURL url() const { return m_strURL; }
00083
00087 bool hideErrorDialog() const;
00088
00092 QString suggestedFilename() const { return m_suggestedFilename; }
00093
00098 QString contentDisposition() const;
00099
00100 bool serverSuggestsSave() const { return contentDisposition() == QString::fromLatin1("attachment"); }
00101
00102 enum AskSaveResult { Save, Open, Cancel };
00111 static AskSaveResult askSave( const KURL & url, KService::Ptr offer, const QString& mimeType, const QString & suggestedFilename = QString::null );
00112
00113 enum AskEmbedOrSaveFlags { InlineDisposition = 0, AttachmentDisposition = 1 };
00123 static AskSaveResult askEmbedOrSave( const KURL & url, const QString& mimeType, const QString & suggestedFilename = QString::null, int flags = 0 );
00124
00125
00126 virtual void save( const KURL & url, const QString & suggestedFilename );
00127
00128
00129 static void simpleSave( const KURL & url, const QString & suggestedFilename,
00130 QWidget* window );
00131
00133 static void simpleSave( const KURL & url, const QString & suggestedFilename );
00134
00135 static bool allowExecution( const QString &serviceType, const KURL &url );
00136
00138 static bool isExecutable( const QString &serviceType );
00139 static bool isTextExecutable( const QString &serviceType );
00140
00141 protected:
00145 virtual void scanFile();
00149 virtual void init();
00157 virtual void handleError( KIO::Job * job );
00158
00163 enum NonEmbeddableResult { Handled, NotHandled, Delayed };
00164
00168 NonEmbeddableResult handleNonEmbeddable( const QString& mimeType );
00169
00170 protected slots:
00171 void slotBrowserScanFinished(KIO::Job *job);
00172 void slotBrowserMimetype(KIO::Job *job, const QString &type);
00173 void slotCopyToTempFileResult(KIO::Job *job);
00174 virtual void slotStatResult( KIO::Job *job );
00175
00176 protected:
00177 KParts::URLArgs m_args;
00178 KParts::ReadOnlyPart *m_part;
00179 QGuardedPtr<QWidget> m_window;
00180
00181
00182 QString m_suggestedFilename;
00183 QString m_sMimeType;
00184 bool m_bRemoveReferrer;
00185 bool m_bTrustedSource;
00186 private:
00187 void redirectToError( int error, const QString& errorText );
00188 class BrowserRunPrivate;
00189 BrowserRunPrivate* d;
00190
00191 };
00192 }
00193 #endif
|