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
00145 URLArgsPrivate *d;
00146 };
00147
00148 struct WindowArgsPrivate;
00149
00155 struct WindowArgs
00156 {
00157 WindowArgs();
00158 WindowArgs( const WindowArgs &args );
00159 WindowArgs &operator=( const WindowArgs &args );
00160 WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
00161 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable );
00162 WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
00163 bool _menuBarVisible, bool _toolBarsVisible,
00164 bool _statusBarVisible, bool _resizable );
00165
00166
00167 int x;
00168 int y;
00169
00170 int width;
00171 int height;
00172 bool fullscreen;
00173 bool menuBarVisible;
00174 bool toolBarsVisible;
00175 bool statusBarVisible;
00176 bool resizable;
00177
00178 bool lowerWindow;
00179
00180 WindowArgsPrivate *d;
00181 };
00182
00183 class OpenURLEvent : public Event
00184 {
00185 public:
00186 OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() );
00187 virtual ~OpenURLEvent();
00188
00189 ReadOnlyPart *part() const { return m_part; }
00190 KURL url() const { return m_url; }
00191 URLArgs args() const { return m_args; }
00192
00193 static bool test( const QEvent *event ) { return Event::test( event, s_strOpenURLEvent ); }
00194
00195 private:
00196 static const char *s_strOpenURLEvent;
00197 ReadOnlyPart *m_part;
00198 KURL m_url;
00199 URLArgs m_args;
00200
00201 class OpenURLEventPrivate;
00202 OpenURLEventPrivate *d;
00203 };
00204
00205 class BrowserExtensionPrivate;
00206
00268 class BrowserExtension : public QObject
00269 {
00270 Q_OBJECT
00271 Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled )
00272 public:
00279 BrowserExtension( KParts::ReadOnlyPart *parent,
00280 const char *name = 0L );
00281
00282
00283 virtual ~BrowserExtension();
00284
00290 virtual void setURLArgs( const URLArgs &args );
00291
00297 URLArgs urlArgs() const;
00298
00304 virtual int xOffset();
00310 virtual int yOffset();
00311
00319 virtual void saveState( QDataStream &stream );
00320
00328 virtual void restoreState( QDataStream &stream );
00329
00335 bool isURLDropHandlingEnabled() const;
00336
00347 void setURLDropHandlingEnabled( bool enable );
00348
00349 void setBrowserInterface( BrowserInterface *impl );
00350 BrowserInterface *browserInterface() const;
00351
00358 bool isActionEnabled( const char * name ) const;
00359
00360 typedef QMap<QCString,QCString> ActionSlotMap;
00389 static ActionSlotMap actionSlotMap();
00390
00395 static ActionSlotMap * actionSlotMapPtr();
00396
00401 static BrowserExtension *childObject( QObject *obj );
00402
00403
00404 #undef signals
00405 #define signals public
00406 signals:
00407 #undef signals
00408 #define signals protected
00409
00414 void enableAction( const char * name, bool enabled );
00415
00422 void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00423
00430 void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00431
00447 void openURLNotify();
00448
00452 void setLocationBarURL( const QString &url );
00453
00457 void setIconURL( const KURL &url );
00458
00466 void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00467
00475 void createNewWindow( const KURL &url, const KParts::URLArgs &args,
00476 const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );
00477
00486 void loadingProgress( int percent );
00490 void speedProgress( int bytesPerSecond );
00491
00492 void infoMessage( const QString & );
00493
00498 void popupMenu( const QPoint &global, const KFileItemList &items );
00499
00506 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items );
00507
00516 void popupMenu( const QPoint &global, const KURL &url,
00517 const QString &mimeType, mode_t mode = (mode_t)-1 );
00518
00528 void popupMenu( KXMLGUIClient *client,
00529 const QPoint &global, const KURL &url,
00530 const QString &mimeType, mode_t mode = (mode_t)-1 );
00531
00537 void selectionInfo( const KFileItemList &items );
00542 void selectionInfo( const QString &text );
00547 void selectionInfo( const KURL::List &urls );
00548
00553 void mouseOverInfo( const KFileItem* item );
00554
00555 private slots:
00556 void slotCompleted();
00557 void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args );
00558 void slotEmitOpenURLRequestDelayed();
00559 void slotEnableAction( const char *, bool );
00560
00561 private:
00562 KParts::ReadOnlyPart *m_part;
00563 URLArgs m_args;
00564 public:
00565 typedef QMap<QCString,int> ActionNumberMap;
00566
00567 private:
00568 static ActionNumberMap * s_actionNumberMap;
00569 static ActionSlotMap * s_actionSlotMap;
00570 static void createActionSlotMap();
00571 protected:
00572 virtual void virtual_hook( int id, void* data );
00573 private:
00574 BrowserExtensionPrivate *d;
00575 };
00576
00582 class BrowserHostExtension : public QObject
00583 {
00584 Q_OBJECT
00585 public:
00586 BrowserHostExtension( KParts::ReadOnlyPart *parent,
00587 const char *name = 0L );
00588
00589 virtual ~BrowserHostExtension();
00590
00596 virtual QStringList frameNames() const;
00597
00604 virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
00605
00610 virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
00611
00616 static BrowserHostExtension *childObject( QObject *obj );
00617
00618 protected:
00619 virtual void virtual_hook( int id, void* data );
00620 private:
00621 class BrowserHostExtensionPrivate;
00622 BrowserHostExtensionPrivate *d;
00623 };
00624
00631 class LiveConnectExtension : public QObject
00632 {
00633 Q_OBJECT
00634 public:
00635 enum Type {
00636 TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString
00637 };
00638 typedef QValueList<QPair<Type, QString> > ArgList;
00639
00640 LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L );
00641
00642 virtual ~LiveConnectExtension() {}
00646 virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value );
00650 virtual bool put( const unsigned long objid, const QString & field, const QString & value );
00654 virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value );
00658 virtual void unregister( const unsigned long objid );
00659
00660 static LiveConnectExtension *childObject( QObject *obj );
00661 signals:
00665 virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args );
00666 };
00667
00668 };
00669
00670 #endif
00671