00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __kparts_browserextension_h__
00022 #define __kparts_browserextension_h__
00023
00024 #include <sys/types.h>
00025
00026 #include <qpoint.h>
00027 #include <qptrlist.h>
00028 #include <qdatastream.h>
00029 #include <qstringlist.h>
00030
00031 #include <kparts/part.h>
00032 #include <kparts/event.h>
00033
00034 class KFileItem;
00035 typedef QPtrList<KFileItem> KFileItemList;
00036 class QString;
00037
00038 namespace KParts {
00039
00040 class BrowserInterface;
00041
00042 struct URLArgsPrivate;
00043
00056 struct URLArgs
00057 {
00058 URLArgs();
00059 URLArgs( const URLArgs &args );
00060 URLArgs &operator=( const URLArgs &args);
00061
00062 URLArgs( bool reload, int xOffset, int yOffset, const QString &serviceType = QString::null );
00063 virtual ~URLArgs();
00064
00069 QStringList docState;
00070
00074 bool reload;
00080 int xOffset;
00084 int yOffset;
00088 QString serviceType;
00089
00093 QByteArray postData;
00097 void setContentType( const QString & contentType );
00101 QString contentType() const;
00106 void setDoPost( bool enable );
00111 bool doPost() const;
00112
00118 void setLockHistory( bool lock );
00119 bool lockHistory() const;
00120
00124 void setNewTab( bool newTab );
00125 bool newTab() const;
00126
00131 QMap<QString, QString> &metaData();
00132
00136 QString frameName;
00137
00143 bool trustedSource;
00144
00148 bool redirectedRequest () const;
00149
00153 void setRedirectedRequest(bool redirected);
00154
00155 URLArgsPrivate *d;
00156 };
00157
00158 struct WindowArgsPrivate;
00159
00165 struct WindowArgs
00166 {
00167 WindowArgs();
00168 WindowArgs( const WindowArgs &args );
00169 WindowArgs &operator=( const WindowArgs &args );
00170 WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
00171 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable );
00172 WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
00173 bool _menuBarVisible, bool _toolBarsVisible,
00174 bool _statusBarVisible, bool _resizable );
00175
00176
00177 int x;
00178 int y;
00179
00180 int width;
00181 int height;
00182 bool fullscreen;
00183 bool menuBarVisible;
00184 bool toolBarsVisible;
00185 bool statusBarVisible;
00186 bool resizable;
00187
00188 bool lowerWindow;
00189
00190 WindowArgsPrivate *d;
00191 };
00192
00193 class OpenURLEvent : public Event
00194 {
00195 public:
00196 OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() );
00197 virtual ~OpenURLEvent();
00198
00199 ReadOnlyPart *part() const { return m_part; }
00200 KURL url() const { return m_url; }
00201 URLArgs args() const { return m_args; }
00202
00203 static bool test( const QEvent *event ) { return Event::test( event, s_strOpenURLEvent ); }
00204
00205 private:
00206 static const char *s_strOpenURLEvent;
00207 ReadOnlyPart *m_part;
00208 KURL m_url;
00209 URLArgs m_args;
00210
00211 class OpenURLEventPrivate;
00212 OpenURLEventPrivate *d;
00213 };
00214
00215 class BrowserExtensionPrivate;
00216
00278 class BrowserExtension : public QObject
00279 {
00280 Q_OBJECT
00281 Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled )
00282 public:
00289 BrowserExtension( KParts::ReadOnlyPart *parent,
00290 const char *name = 0L );
00291
00292
00293 virtual ~BrowserExtension();
00294
00300 virtual void setURLArgs( const URLArgs &args );
00301
00307 URLArgs urlArgs() const;
00308
00314 virtual int xOffset();
00320 virtual int yOffset();
00321
00329 virtual void saveState( QDataStream &stream );
00330
00338 virtual void restoreState( QDataStream &stream );
00339
00345 bool isURLDropHandlingEnabled() const;
00346
00357 void setURLDropHandlingEnabled( bool enable );
00358
00359 void setBrowserInterface( BrowserInterface *impl );
00360 BrowserInterface *browserInterface() const;
00361
00368 bool isActionEnabled( const char * name ) const;
00369
00370 typedef QMap<QCString,QCString> ActionSlotMap;
00399 static ActionSlotMap actionSlotMap();
00400
00405 static ActionSlotMap * actionSlotMapPtr();
00406
00411 static BrowserExtension *childObject( QObject *obj );
00412
00413
00414 #undef signals
00415 #define signals public
00416 signals:
00417 #undef signals
00418 #define signals protected
00419
00424 void enableAction( const char * name, bool enabled );
00425
00432 void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00433
00440 void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00441
00457 void openURLNotify();
00458
00462 void setLocationBarURL( const QString &url );
00463
00467 void setIconURL( const KURL &url );
00468
00476 void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00477
00485 void createNewWindow( const KURL &url, const KParts::URLArgs &args,
00486 const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );
00487
00496 void loadingProgress( int percent );
00500 void speedProgress( int bytesPerSecond );
00501
00502 void infoMessage( const QString & );
00503
00508 void popupMenu( const QPoint &global, const KFileItemList &items );
00509
00516 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items );
00517
00526 void popupMenu( const QPoint &global, const KURL &url,
00527 const QString &mimeType, mode_t mode = (mode_t)-1 );
00528
00538 void popupMenu( KXMLGUIClient *client,
00539 const QPoint &global, const KURL &url,
00540 const QString &mimeType, mode_t mode = (mode_t)-1 );
00541
00547 void selectionInfo( const KFileItemList &items );
00552 void selectionInfo( const QString &text );
00557 void selectionInfo( const KURL::List &urls );
00558
00563 void mouseOverInfo( const KFileItem* item );
00564
00565 private slots:
00566 void slotCompleted();
00567 void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args );
00568 void slotEmitOpenURLRequestDelayed();
00569 void slotEnableAction( const char *, bool );
00570
00571 private:
00572 KParts::ReadOnlyPart *m_part;
00573 URLArgs m_args;
00574 public:
00575 typedef QMap<QCString,int> ActionNumberMap;
00576
00577 private:
00578 static ActionNumberMap * s_actionNumberMap;
00579 static ActionSlotMap * s_actionSlotMap;
00580 static void createActionSlotMap();
00581 protected:
00582 virtual void virtual_hook( int id, void* data );
00583 private:
00584 BrowserExtensionPrivate *d;
00585 };
00586
00592 class BrowserHostExtension : public QObject
00593 {
00594 Q_OBJECT
00595 public:
00596 BrowserHostExtension( KParts::ReadOnlyPart *parent,
00597 const char *name = 0L );
00598
00599 virtual ~BrowserHostExtension();
00600
00606 virtual QStringList frameNames() const;
00607
00613 virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
00614
00620 BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame);
00621
00626 virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
00627
00632 static BrowserHostExtension *childObject( QObject *obj );
00633
00634 protected:
00640 enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 };
00641 struct FindFrameParentParams
00642 {
00643 BrowserHostExtension *parent;
00644 KParts::ReadOnlyPart *callingPart;
00645 QString frame;
00646 };
00647
00648 virtual void virtual_hook( int id, void* data );
00649 private:
00650 class BrowserHostExtensionPrivate;
00651 BrowserHostExtensionPrivate *d;
00652 };
00653
00660 class LiveConnectExtension : public QObject
00661 {
00662 Q_OBJECT
00663 public:
00664 enum Type {
00665 TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString
00666 };
00667 typedef QValueList<QPair<Type, QString> > ArgList;
00668
00669 LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L );
00670
00671 virtual ~LiveConnectExtension() {}
00675 virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value );
00679 virtual bool put( const unsigned long objid, const QString & field, const QString & value );
00683 virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value );
00687 virtual void unregister( const unsigned long objid );
00688
00689 static LiveConnectExtension *childObject( QObject *obj );
00690 signals:
00694 virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args );
00695 };
00696
00697 }
00698
00699 #endif
00700