kparts Library API Documentation

browserrun.h

00001 /* This file is part of the KDE project
00002  *
00003  * Copyright (C) 2002 David Faure <faure@kde.org>
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License version 2, as published by the Free Software Foundation.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public License
00014  * along with this library; see the file COPYING.LIB.  If not, write to
00015  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016  * Boston, MA 02111-1307, USA.
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 
00039     class KPARTS_EXPORT BrowserRun : public KRun
00040     {
00041         Q_OBJECT
00042     public:
00052         BrowserRun( const KURL& url, const KParts::URLArgs& args,
00053                     KParts::ReadOnlyPart *part, QWidget *window,
00054                     bool removeReferrer, bool trustedSource );
00055 
00056         // BIC: merge with above constructor
00067         BrowserRun( const KURL& url, const KParts::URLArgs& args,
00068                     KParts::ReadOnlyPart *part, QWidget *window,
00069                     bool removeReferrer, bool trustedSource, bool hideErrorDialog );
00070 
00071         virtual ~BrowserRun();
00072 
00073         //KParts::URLArgs urlArgs() const { return m_args; }
00074         //KParts::ReadOnlyPart* part() const { return m_part; }
00075         KURL url() const { return m_strURL; }
00076 
00077         bool hideErrorDialog() const;
00078         
00079         // Suggested filename given by the server (e.g. HTTP content-disposition)
00080         QString suggestedFilename() const { return m_suggestedFilename; }
00081         
00082         enum AskSaveResult { Save, Open, Cancel };
00091         static AskSaveResult askSave( const KURL & url, KService::Ptr offer, const QString& mimeType, const QString & suggestedFilename = QString::null );
00101         static AskSaveResult askEmbedOrSave( const KURL & url, const QString& mimeType, const QString & suggestedFilename = QString::null, int flags = 0 );
00102 
00103         // virtual so that KHTML can implement differently (HTML cache)
00104         virtual void save( const KURL & url, const QString & suggestedFilename );
00105 
00106         // static so that it can be called from other classes
00107         static void simpleSave( const KURL & url, const QString & suggestedFilename,
00108                                 QWidget* window );
00109 
00111         static void simpleSave( const KURL & url, const QString & suggestedFilename );
00112 
00113         static bool allowExecution( const QString &serviceType, const KURL &url );
00114 
00116         static bool isExecutable( const QString &serviceType );
00117         static bool isTextExecutable( const QString &serviceType );
00118 
00119     protected:
00123         virtual void scanFile();
00127         virtual void init();
00135         virtual void handleError( KIO::Job * job );
00136 
00141         enum NonEmbeddableResult { Handled, NotHandled, Delayed };
00142 
00146         NonEmbeddableResult handleNonEmbeddable( const QString& mimeType );
00147 
00148     protected slots:
00149         void slotBrowserScanFinished(KIO::Job *job);
00150         void slotBrowserMimetype(KIO::Job *job, const QString &type);
00151         void slotCopyToTempFileResult(KIO::Job *job);
00152         virtual void slotStatResult( KIO::Job *job );
00153 
00154     protected:
00155         KParts::URLArgs m_args;
00156         KParts::ReadOnlyPart *m_part; // QGuardedPtr?
00157         QGuardedPtr<QWidget> m_window;
00158         // Suggested filename given by the server (e.g. HTTP content-disposition)
00159         // When set, we should really be saving instead of embedding
00160         QString m_suggestedFilename;
00161         QString m_sMimeType;
00162         bool m_bRemoveReferrer;
00163         bool m_bTrustedSource;
00164     private:
00165         void redirectToError( int error, const QString& errorText );
00166         class BrowserRunPrivate;
00167         BrowserRunPrivate* d;
00168 
00169     };
00170 }
00171 #endif
KDE Logo
This file is part of the documentation for kparts Library Version 3.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 8 08:03:01 2006 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003