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
00094 enum AskSaveResult { Save, Open, Cancel };
00103 static AskSaveResult askSave( const KURL & url, KService::Ptr offer, const QString& mimeType, const QString & suggestedFilename = QString::null );
00113 static AskSaveResult askEmbedOrSave( const KURL & url, const QString& mimeType, const QString & suggestedFilename = QString::null, int flags = 0 );
00114
00115
00116 virtual void save( const KURL & url, const QString & suggestedFilename );
00117
00118
00119 static void simpleSave( const KURL & url, const QString & suggestedFilename,
00120 QWidget* window );
00121
00123 static void simpleSave( const KURL & url, const QString & suggestedFilename );
00124
00125 static bool allowExecution( const QString &serviceType, const KURL &url );
00126
00128 static bool isExecutable( const QString &serviceType );
00129 static bool isTextExecutable( const QString &serviceType );
00130
00131 protected:
00135 virtual void scanFile();
00139 virtual void init();
00147 virtual void handleError( KIO::Job * job );
00148
00153 enum NonEmbeddableResult { Handled, NotHandled, Delayed };
00154
00158 NonEmbeddableResult handleNonEmbeddable( const QString& mimeType );
00159
00160 protected slots:
00161 void slotBrowserScanFinished(KIO::Job *job);
00162 void slotBrowserMimetype(KIO::Job *job, const QString &type);
00163 void slotCopyToTempFileResult(KIO::Job *job);
00164 virtual void slotStatResult( KIO::Job *job );
00165
00166 protected:
00167 KParts::URLArgs m_args;
00168 KParts::ReadOnlyPart *m_part;
00169 QGuardedPtr<QWidget> m_window;
00170
00171
00172 QString m_suggestedFilename;
00173 QString m_sMimeType;
00174 bool m_bRemoveReferrer;
00175 bool m_bTrustedSource;
00176 private:
00177 void redirectToError( int error, const QString& errorText );
00178 class BrowserRunPrivate;
00179 BrowserRunPrivate* d;
00180
00181 };
00182 }
00183 #endif
|